Windows下用Python 3.4+自带的venv模块创建虚拟环境
来源:互联网 发布:用java求质数 编辑:程序博客网 时间:2024/04/29 08:48
转自:http://www.cnblogs.com/animalize/p/5868763.html
Python 3.4+自带了venv模块,用于创建虚拟环境,每个虚拟环境都可以安装一套独立的第三方模块。
本文在Windows 10上操作。
1、创建一个虚拟环境:
D:\>mkdir test_venvD:\>cd test_venvD:\test_venv>python -m venv test
第三行,使用venv模块创建一个名为test的虚拟环境。
执行后,生成了一个test目录,内有1个文件、3个目录:
test
│ pyvenv.cfg
│
├─Include
├─Lib
└─Scripts
2、启用虚拟环境:
D:\test_venv>test\Scripts\activate.bat(test) D:\test_venv>
执行那个activate.bat文件,启用后,提示符前面会出现虚拟环境的名字(test)。
3、用pip给虚拟环境安装模块:
用pip list看一下已有的模块,能看到只有两个Python自带的模块:
(test) D:\test_venv>pip listpip (8.1.1)setuptools (20.10.1)You are using pip version 8.1.1, however version 8.1.2 is available.You should consider upgrading via the 'python -m pip install --upgrade pip' command.
提示pip有新版本,按提示用'python -m pip install --upgrade pip'命令更新就好了。
在虚拟环境里,千万别用'pip install --upgrade pip'更新pip,这会破坏pip。
现在,给虚拟环境安装tornado试试:
(test) D:\test_venv>pip install tornadoCollecting tornado Using cached tornado-4.4.1-cp35-cp35m-win_amd64.whlInstalling collected packages: tornadoSuccessfully installed tornado-4.4.1
已成功安装tornado。
4、退出虚拟环境:
(test) D:\test_venv>test\Scripts\deactivate.batD:\test_venv>
执行deactivate.bat后,退出虚拟环境,此时命令行提示符前的(test)消失了。
0 0
- Windows下用Python 3.4+自带的venv模块创建虚拟环境
- Windows下用Python 3.4+自带的venv模块创建虚拟环境
- Python 3 使用venv创建虚拟环境
- Python3 venv 创建虚拟环境
- python venv 虚拟环境配置 gpu
- Windows下创建python虚拟环境
- windows 用virtualenv创建不同python版本的虚拟环境
- Windows下用PowerShell激活Python的虚拟环境
- windows环境下python虚拟环境的搭建
- Windows的wamp环境下创建虚拟站点/虚拟目录
- Ubuntu系统下python虚拟环境的创建和使用
- windows下 python 自带的CGIHTTPServer使用
- 利用python自带的os模块删除windows机器的模块
- windows 下使用 virtualenv 创建虚拟环境
- Windows下使用conda创建虚拟环境
- Python的虚拟环境安装(windows下)
- MAC下创建python虚拟环境
- Ubuntu下创建python虚拟开发环境
- 程序员,如何从平庸走向理想?
- Vitamio视频播放
- Map<String, Object> map = new HashMap<String, Object>(existMap)解析
- TCP的拥塞控制
- usbfs
- Windows下用Python 3.4+自带的venv模块创建虚拟环境
- HDU2544 最短路——Floyd
- TCP的几个状态 (SYN, FIN, ACK, PSH, RST, URG)
- js数据类型 ——引用类型(Array).1/3
- spring源码解析(二)IOC容器
- 最大子序列和算法
- Oracle建立索引及SQL优化
- oracle数据库数据统计问题
- canvas中的状态保存与恢复