C:\Users\tianw1>pywin
Python 2.7.7 (default, Jun 1 2014, 14:17:13) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
2. 打开Python 3.4
C:\Users\tianw1>pywin -3.4
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
3. 将Python 3.4设置为默认的Python执行环境,根据输出也可以看出,其实就是将Python 3.4目录放在环境变量PATH的前面位置
C:\Users\tianw1>pywin setdefault 3.4
Setting default python for active session to: 3.4
C:\Python34;C:\Python34\Scripts -- now at front of PATH
# 由于Python 3.4中没有安装pywin,所以会报错
C:\Users\tianw1>pywin
'pywin' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\tianw1>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
4. 即使上面通过pywin将默认Python版本环境设为3.4,但是由于文件的查找还是先本地,然后环境变量PATH。所以,下面方式使用的还是2.7版本,同时也可以再通过pywin将2.7设置为默认Python版本环境。
C:\>cd Python27
C:\Python27>python
Python 2.7.7 (default, Jun 1 2014, 14:17:13) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
C:\Python27>pywin setdefault 2.7
Setting default python for active session to: 2.7
C:\Python27;C:\Python27\Scripts -- now at front of PATH
C:\Python27> virtualenvwrapper-win
在Windows环境中使用"virtualenvwrapper-win"还是比较方便的。
C:\Users\tianw1>workon
Pass a name to activate one of the following virtualenvs:
==============================================================================
py27_dev1
py27_dev2
C:\Users\tianw1>lsvirtualenv
dir /b /ad "C:\Users\tianw1\Envs"
==============================================================================
py27_dev1
py27_dev2
C:\Users\tianw1>
4. 删除虚拟环境:rmvirtualenv env_name