Windows使用Python虚拟环境

Windows使用virtualenv和virtualenvwrapper-win

Windows上使用virtualenv进行多版本Python隔离.

安装Python

Python官网下载Python 3.X or Python 2.X, 双击安装记得勾选Add to Path,

cmd中输入Python, 测试Path路径是否正确, 如果没有进入Python shell中, 进入Python安装目录, 复制路径, 右键此电脑-->属性-->高级系统设置-->环境变量-->系统变量-->Path-->编辑-->新建-->粘贴最后加一个.

cmd中再次测试.

安装virtualenv和virtualenvwrapper-win

pip install virtualenv

Windows使用virtualenvwrapper-win,
pip install virtualenvwrapper-win

添加WORKON_HOME路径, 右键此电脑-->属性-->高级系统设置-->环境变量-->系统变量-->新建, 变量名为WORKON_HOME, 变量值为创建的虚拟目录的路径.

创建虚拟目录

WORKON_HOME目录中, 使用virtualenv --no-site-package py2, 如果不使用virtualenvwrapper-win, 需要进入py2/Scripts/下面, 执行activate.bat, 退出需要执行deactivate.bat.

使用workon py2可以直接进入虚拟环境.

原文地址:https://www.cnblogs.com/zzhaolei/p/11068175.html