Install the Python Virtual Environment virtualenvwrapper-win and virtualenvwrapper in windows

Source: Internet
Author: User
Tags virtualenv

[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.

PassvirtualenvThis tool can build a seriesVirtual Python EnvironmentAnd 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
1 pip install virtualenv
Ii. basic use of virtualenv 2.1 to create a virtual environment
1 virtualenv venv

Specify the Python interpreter for the environment:

1 virtualenv -p c:\python27\python.exe venv
2.2 activate the Virtual Environment
1 activate venv
2.3 stop the Virtual Environment
1 deactivate
2.4 delete a virtual environment

Directly Delete the directory.

1 rmvirtualenv venv 
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?
  1. Mkvirtualenv venv

After the creation, the environment is automatically activated. Check the Shell prompt changes:

1 (venv)c:\>
3.3 list all Virtual Environments
1 lsvirtualenv
3.4 activate the Virtual Environment
1 workon venv 
3.5 enter the virtual environment directory
1 cdvirtualenv
3.6 enter the site-packages directory of the Virtual Environment
1 cdsitepackages
3.7 list all software packages in the site-packages directory
1 lssitepackages
3.8 stop the Virtual Environment
1 deactivate
3.9 delete a virtual environment
1 rmvitualenv venv
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.