多版本python共存的解决方案
不同版本python切换的方法
利用Windows Launcher
py -2.7 py -3 py -3 script.py
在python file头添加Unix-style top-of-script comments,如
#!python2 #!/usr/bin/python2.7 #!/usr/bin/env python3
修改Windows 环境变量PATH设置
系统->高级系统设置->环境变量->path->编辑
然後去手動把 python27下面的python.exe改成python2.exe
python35下面的python.exe改成python3.exe
在CMD输入
python2
运行python2,输入python3运行python3
多版本python共存下使用pip
py -2 -m pip install XXXX
py -3 -m pip install XXXX
python [-bBdEhiIOqsSuvVWx?] [-c command | -m module-name | script | - ] [args]
-m
Search sys.path for the named module and execute its contents as the
__main__
module.Since the argument is a module name, you must not give a file extension (.py). The module-name should be a valid Python module name, but the implementation may not always enforce this (e.g. it may allow you to use a name that includes a hyphen).
Package names (including namespace packages) are also permitted. When a package name is supplied instead of a normal module, the interpreter will execute
<pkg>.__main__
as the main module. This behaviour is deliberately similar to the handling of directories and zipfiles that are passed to the interpreter as the script argument.
所以 py -3 -m pip
会运行C:\Python34\Lib\site-packages\pip
路径下的__main__.py