Installing the Python virtual environment under Windows Virtualenvwrapper-win

Source: Internet
Author: User
Tags virtual environment virtualenv

Because of the numerous versions of Python, there are also Python2 and Python3 debates, so some packages or third-party libraries are prone to version incompatibility issues.

Passvirtualenv

This tool, you can build a series of 虚拟的python环境, and then install the required packages in each environment (with pipUse), this series of environments are isolated from each other. As a standalone environment, version issues are not easily available and are also easy to deploy.

2 installation
Pip Install Virtualenv
3 Basic use of VIRTUALENV 3.1 create a virtual environment
Virtualenv venv

To specify the Python interpreter for the environment:

Virtualenv-p C:\python27\python.exe venv
3.2 Activating a virtual environment
Activate Venv
3.3 Stopping a virtual environment
Deactivate
3.4 Deleting a virtual environment

Delete the directory directly.

Rmvirtualenv venv
4 Virtualenvwrapper

In order to use the virtualenv more convenient, you can rely onvirtualenvwrapper

4.1 Installing Virtualenvwrapper
Pip Install Virtualenvwrapper-win
4.2 Creating a virtual environment

The virtual environment created by default is located in C:\Users\username\envs and can be passed through environment variablesWORKON_HOME

To customize.

By computer--Properties--Advanced system settings--environment variables--NEW "variable name" in System variables: workon_home, Variable value: "Your custom Path".

Execute this command to create a first virtual environment:

Once created, the environment is automatically activated, taking note of changes to the shell prompt:

(venv) c:\>
4.3 List all Virtual environments
Lsvirtualenv
4.4 Activating a virtual environment
Workon venv
4.5 Entering the Virtual environment directory
Cdvirtualenv
4.6 Enter the Site-packages directory of the virtual environment
Cdsitepackages
4.7 Listing all packages for the Site-packages directory
Lssitepackages
4.8 Stopping a virtual environment
Deactivate
4.9 Deleting a virtual environment
Rmvitualenv venv
5 Rebuilding the Python Environment 5.1 freezing the environment

Called冻结(freeze)

Environment is to fix the package of the current environment:
Pip Freeze >packages.txt # Install package list saved to file Packages.txt
5.2 Rebuilding the Environment

重建(rebuild)

The environment is in the deployment, install the corresponding version of the package in the production environment, do not appear version compatibility issues:
Pip Install-r packages.txt

With Pip, you can batch install the corresponding version of the package, quickly rebuild the environment, complete the deployment

Installing the Python virtual environment under Windows Virtualenvwrapper-win

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.