python-虚拟环境virtualenv

有时候从github上下载的开源项目想在本地调试运行,发该项目依赖的第三方包与本地环境不一致,这时候就用到python环境虚拟环境了...

windows上搭建步骤:

C:\Users\acer>pip install virtualenv
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/f7/69/1ad2d17560c4fc60170056dcd0a568b83f3453a2ac91155af746bcdb9a07/virtualenv-16.7.4-py2.py3-none-any.whl (3.3MB)
     |████████████████████████████████| 3.3MB 48kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-16.7.4

D:\>e:
E:\>virtualenv py36_testenv      # 创建名称为py36_testenv的虚拟环境
Using base prefix 'e:\\soft\\python\\python36'
New python executable in E:\py36_testenv\Scripts\python.exe
Installing setuptools, pip, wheel...
done.

E:\>dir
 驱动器 E 中的卷是 本地磁盘
 卷的序列号是 F460-F4B7

 E:\ 的目录

2019/07/22  21:49    <DIR>          360用户文件
2019/08/25  23:42    <DIR>          BaiduNetdiskDownload
2019/08/21  23:40    <DIR>          linux_chao
2019/08/31  10:31    <DIR>          myproj
2019/08/31  23:55    <DIR>          py36_testenv
2019/08/22  20:43    <DIR>          robot
2019/08/07  21:04    <DIR>          soft
2019/07/15  22:48    <DIR>          test
2019/06/06  20:31    <DIR>          逸曜
               0 个文件              0 字节
               9 个目录 108,580,327,424 可用字节

E:\>cd py36_testenv

E:\py36_testenv>cd Scripts

E:\py36_testenv\Scripts>dir
 驱动器 E 中的卷是 本地磁盘
 卷的序列号是 F460-F4B7

 E:\py36_testenv\Scripts 的目录

2019/08/31  23:56    <DIR>          .
2019/08/31  23:56    <DIR>          ..
2019/08/31  23:56             2,295 activate
2019/08/31  23:56               873 activate.bat
2019/08/31  23:56             1,755 activate.ps1
2019/08/31  23:56             1,149 activate.xsh
2019/08/31  23:56             1,517 activate_this.py
2019/08/31  23:56               512 deactivate.bat
2019/08/31  23:55           102,773 easy_install-3.6.exe
2019/08/31  23:55           102,773 easy_install.exe
2019/08/31  23:56           102,755 pip.exe
2019/08/31  23:56           102,755 pip3.6.exe
2019/08/31  23:56           102,755 pip3.exe
2019/08/31  23:55           100,504 python.exe
2019/08/31  23:55            58,520 python3.dll
2019/08/31  23:55         3,610,776 python36.dll
2019/08/31  23:55            98,968 pythonw.exe
2019/08/31  23:56           102,751 wheel.exe
              16 个文件      4,493,431 字节
               2 个目录 108,580,327,424 可用字节

E:\py36_testenv\Scripts>activate     # 激活虚拟环境

(py36_testenv) E:\py36_testenv\Scripts>pip install pytest==3.6.3

(py36_testenv) E:\py36_testenv\Scripts>deactivate # 退出虚拟环境

猜你喜欢

转载自www.cnblogs.com/wang-mengmeng/p/11441074.html