python虚拟环境

pip3 install virtualenv   #安装虚拟环境

C:\Users\Administrator>virtualenv testdir1     #创建一个名为testdir1的虚拟python环境
Using base prefix 'd:\\python\\python36'
New python executable in C:\Users\Administrator\testdir1\Scripts\python.exe
Installing setuptools, pip, wheel...done.

C:\Users\Administrator>cd testdir1       #进入目录


C:\Users\Administrator\testdir1>dir        #查看目录
驱动器 C 中的卷没有标签。
卷的序列号是 FE12-B6A3

C:\Users\Administrator\testdir1 的目录

2017/07/13 14:25 <DIR> .
2017/07/13 14:25 <DIR> ..
2017/05/05 11:53 <DIR> Include
2017/07/13 14:24 <DIR> Lib
2017/07/13 14:25 60 pip-selfcheck.json
2017/07/13 14:25 <DIR> Scripts
2017/07/13 14:24 <DIR> tcl
1 个文件 60 字节
6 个目录 45,641,490,432 可用字节

C:\Users\Administrator\testdir1>cd Scripts

C:\Users\Administrator\testdir1\Scripts>dir
驱动器 C 中的卷没有标签。
卷的序列号是 FE12-B6A3

C:\Users\Administrator\testdir1\Scripts 的目录

2017/07/13 14:25 <DIR> .
2017/07/13 14:25 <DIR> ..
2017/07/13 14:25 2,197 activate
2017/07/13 14:25 771 activate.bat
2017/07/13 14:25 8,325 activate.ps1
2017/07/13 14:25 1,137 activate_this.py
2017/07/13 14:25 508 deactivate.bat
2017/07/13 14:24 98,181 easy_install-3.6.exe
2017/07/13 14:24 98,181 easy_install.exe
2017/07/13 14:25 98,153 pip.exe
2017/07/13 14:25 98,153 pip3.6.exe
2017/07/13 14:25 98,153 pip3.exe
2017/07/13 14:24 100,504 python.exe
2017/07/13 14:24 3,562,648 python36.dll
2017/07/13 14:24 98,968 pythonw.exe
2017/07/13 14:25 98,160 wheel.exe
14 个文件 4,364,039 字节
2 个目录 45,641,494,528 可用字节

C:\Users\Administrator\testdir1\Scripts>activate.bat              #启用该虚拟环境


(testdir1) C:\Users\Administrator\testdir1\Scripts>pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.con
f under the [list] section) to disable this warning.
pip (9.0.1)
setuptools (36.0.1)
wheel (0.29.0)

(testdir1) C:\Users\Administrator\testdir1\Scripts>

 


pip3 install virtualenvwrapper-win             (windows 安装 virtualenv的增强版)
pip3 install virtualenvwrapper                (linux 安装 virtualenv的增强版)

C:\Users\Administrator>pip3 install virtualenvwrapper-win
Collecting virtualenvwrapper-win
Requirement already satisfied: virtualenv in d:\python\python36\lib\site-packages (from virtualenvwrapper-win)
Installing collected packages: virtualenvwrapper-win
Successfully installed virtualenvwrapper-win-1.2.1

C:\Users\Administrator>mkvirtualenv testdir2           #创建一个名为testdir2的python虚拟环境
Using base prefix 'd:\\python\\python36'
New python executable in C:\Users\Administrator\Envs\testdir2\Scripts\python.exe
Installing setuptools, pip, wheel...done.

(testdir2) C:\Users\Administrator>workon             #查看所有虚拟环境列表

Pass a name to activate one of the following virtualenvs:
==============================================================================
mxonline
testdir2
testvir2

(testdir2) C:\Users\Administrator>workon testdir2           #切换虚拟环境workon
(testdir2) C:\Users\Administrator>workon mxonline
(mxonline) C:\Users\Administrator>deactivate             #退出虚拟环境

C:\Users\Administrator>

 

posted @ 2017-07-13 14:41  粗哥  阅读(257)  评论(0编辑  收藏  举报