PS:以下操作全部基于python2,python3已经自动集成venv模块,直接运行py -m venv venv即可创建虚拟环境
- 安装
virtualenv
pip install virtualenv
- 创建项目目录
mkdir myproject
cd myproject
- 创建一个不拷贝系统
python包
的独立运行环境
virtualenv --no-site-packages venv
Using base prefix 'c:\program files\python37'
New python executable in D:dojopythonvirtualenv_testvenvScriptspython.exe
Installing setuptools, pip, wheel...done.
- 进入虚拟环境
source venv/Scripts/activate
- 退出虚拟环境
source venv/Scripts/deactivate.bat