Linux and Mac use virtualenv for use and installation

Source: Internet
Author: User
Tags virtual environment virtualenv

Virtualenv is one of Python's three great artifacts for creating a standalone Python virtual environment, with multiple versions of Python independent and separate from each other, with multiple versions of Python installed on a single computer without affecting native Python versions. Prevents the installation of many expansion packs, the native Python environment is a mess, the installation method is as follows:

1, install VIRTUALENV, use pip install virtualenv installation or manual download Virtualenv installation package installation, for: https://pypi.python.org/pypi/virtualenv/, After decompression into the directory, Python setup.py install can be;

2, install virtualenvwrapper,virtualenvwrapper is an extension package of virtualenv, it encapsulates some virtualenv methods, easy to create, delete virtual environment and so on, use PIP install Virtualenvwrapper installation or manual download Virtualenvwrapper installation package installation, bit: https://pypi.python.org/pypi/virtualenvwrapper/, after the download is complete, unzip the meter into the directory, Python setup.py install can be;

3, in the virtual machine environment to install the Python expansion pack, virtualenv with the PIP installation tool, you can directly use the PIP install XXX installation, because if the system installed the PIP tool, we in the PIP install Python extension package will be installed in the system's expansion package, not the virtual environment we use, in order to avoid this situation, but also ensure that our system environment is clean, can be in the current user's home directory. bashrc file

Export pip_require_virtualenv=true# indicates that the PIP must be executed in the virtual environment

Export pip_respect_virtualenv=true# indicates that a virtual environment in startup is used automatically when using PIP

4, set the storage location of the virtual machine environment, in the current user home directory. bashrc file:

Export Workon_home= $HOME/.virtualenvs# indicates that the virtual environment is stored in the home directory under the. Virtualenvs folder, the path can be filled in freely

5, source. bashrc# Reload environment variable file

6. Test using VIRTUALENV to create a virtual environment, MKVIRTUALENV test to create a virtual environment in the home directory, is hidden. Using this virtual environment, Workon test can be, into the virtual environment after the random toss, the local environment will not be chaotic, the virtual environment after the problem directly to delete it.

7. Common commands:

Mkvirtualenv Test--system-site-packages #创建一个包含系统扩展包的虚拟环境
Rmvirtualenv Test #删除test这个虚拟环境
Workon Test #切换到test这个虚拟机环境
Workon #显示虚拟环境列表

8, about virtualenv introduced here, it is not very convenient to use it, go and try It

Linux and Mac use virtualenv for use and installation

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.