[Switch] install the Python Virtual Environment virtualenvwrapper-win and virtualenvwrapper in windows
Due to the large number of Python versions and the debate between Python2 and Python3, some software packages or third-party libraries are prone to version incompatibility issues.
Passvirtualenv
This tool can build a seriesVirtual Python Environment
And then install the required software package in each environment (pip
). These environments are isolated from each other. As an independent environment, it is not prone to version problems, but also easy to deploy.
I. Installation
Ii. basic use of virtualenv 2.1 to create a virtual environment
Specify the Python interpreter for the environment:
1 |
virtualenv - p c:\python27\python.exe venv |
2.2 activate the Virtual Environment
2.3 stop the Virtual Environment
2.4 delete a virtual environment
Directly Delete the directory.
Iii. virtualenvwrapper
To make it easier to use virtualenv, you can usevirtualenvwrapper
3.1 install virtualenvwrapper
1 |
pip install virtualenvwrapper - win |
3.2 create a virtual environment
The default virtual environment is in C: \ Users \ username \ envs. You can use the environment variableWORKON_HOME
.
Choose computer> Properties> advanced system Settings> environment variables> Create a new "variable name": WORKON_HOME in the system variables, and set the variable value to "your custom path ".
Run this command to create the first virtual environment:
[Plain]View plain copy print?
- Mkvirtualenv venv
After the creation, the environment is automatically activated. Check the Shell prompt changes:
3.3 list all Virtual Environments
3.4 activate the Virtual Environment
3.5 enter the virtual environment directory
3.6 enter the site-packages directory of the Virtual Environment
3.7 list all software packages in the site-packages directory
3.8 stop the Virtual Environment
3.9 delete a virtual environment
Iv. Rebuilding Python environment 4.1 freeze the environment
The so-calledFreeze)
Environment is to fix the software packages in the current environment:
1 |
pip freeze >packages.txt # Install a package and save it to packages.txt. |
4.2 rebuilding the environment
Rebuild)
When the environment is deployed, install the corresponding version of the software package in the production environment, and do not have version compatibility or other problems:
1 |
pip install - r packages.txt |
With pip, you can install software packages of the corresponding version in batches to quickly reconstruct the environment and complete deployment.
Address: http://blog.csdn.net/iaau0908/article/details/54021518
Author: Jin Xiao
Source: http://www.cnblogs.com/jinxiao-pu/p/6697481.html
The copyright of this article is shared by the author and the blog. You are welcome to repost this article, but you must keep this statement without the author's consent and provide a connection to the original article on the article page.