Python builds multi-version environment--pyenv, Virtualenv toss notes continued

Source: Internet
Author: User
Tags virtual environment virtualenv

What is Virtualenv?

Virtualenv is used to create multiple standalone Python runtime environments on a single machine, Virtualenvwrapper provides some handy package on the command line.

Why do you use

-Isolation of third-party package dependencies between projects, such as a project dependent on Django1.2.5,b project dependent django1.3.
-To facilitate the deployment of applications, the development environment of the virtual environment packaged in a production environment, do not need to be on the server again.

How to use


-Pip Install Virtualenvwrapper
-Add the following sentence to the ~/.bash_profile inside, if not too troublesome, can also be manually executed each time.

Export Workon_home= $HOME/.virtualenvssource/usr/bin/

Note the path to here


Common commands

An innovative virtual environment
-Mkvirtualenv [ENV1]
This command will help us create a new environment, by default, the directory of the environment is. VIRTUALENV/EN1, which automatically installs the PIP for us during the creation process, and can be used to directly use the PIP command when we install new dependencies.
Once created, automatically switches to work in that environment, and you can see that the prompt changes to:
(ENV1) $
Dependencies installed in this environment do not affect other environments
-Lssitepackages shows the packages installed in the environment

Toggle Environment
-Workon [env]
Use "Workon environment name" at any time to make an environment switch, and if you do not have an environment name parameter, display the currently used environment
in an environment. Switch to the system's Python environment

Other commands
-Showvirtualenv [env] Displays details of the specified environment.
-Rmvirtualenv [env] Removes the specified virtual environment, as long as the removal is not currently working in that environment. If working in this environment, first use deactivate to exit.
-cpvirtualenv [Source] [dest] Copies a copy of the virtual environment.
-Cdvirtualenv [SubDir] Sets the current working directory to the Environment directory in which it resides.
-Cdsitepackages [SubDir] Sets the current working directory to the Sitepackages path of the environment in which it is located.
-Add2virtualenv [dir] [dir] adds the specified directory to the path of the currently used environment, which is often used in situations where a larger library is used simultaneously in multiple project.
-Toggleglobalsitepackages-q Controls whether the current environment uses a global sitepackages directory

Python builds multi-version environment--pyenv, Virtualenv toss notes continued

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