Python virtualenv Use summary article

Source: Internet
Author: User

first, the installation of Virtualenv

1. Using PIP to install virtualenv globally, it is recommended to use PIP 1.3 or later, before 1.3, Pip is not downloaded from PyPI via SSL.

$ [sudo] pip install virtualenv

Or the latest unreleased version: (GitHub address may change)

$ [sudo] pip install Https://github.com/pypa/virtualenv/tarball/develop

Other download installation method is not recommended, because the address will change, trouble ... I want to see it.

second, the use of virtualenv

1. Create a virtual environment

Use the following command to create a directory for a virtual environment

$ virtualenv ENV

The following directories are typically found in the generated virtual environment directory:

Lib and include: contains the new virtualenv Python support library file, and the packages installed in the virtual environment will be placed in the lib/pythonx.x/site-packages/.

Bin: The directory has a number of executables, such as Python, running the Bin/python run script that can be executed in that environment. The PIP in this directory also has a similar effect.

2. Activating and deactivating the environment

$ source Bin/activate # Bin/activate applies to Bash/zsh/dash.

This command will change your $path so that the first entry for your $path is the bin/directory of the current virtual environment, and the script will also modify your shell prompt.

When creating a virtual environment, the packages that need to be used to the global can be inherited /usr/lib/python2.7/site-packages(not rigorous here) by using the following:

$ virtualenv--system-site-packages ENV

To undo these actions as you want to run:

$ deactivate

Windows here do not do too much to explain, similar, interested can point here

Python virtualenv Use summary 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.