Virtualenv and Virtualenvwrapper of the standalone Python environment

Source: Internet
Author: User
Tags virtual environment virtualenv

Introduced

If there is a test machine, multi-personal use, there are multiple projects, different items may not be the same Python version number. The library needs to be different.

We need an independent, clean Python environment that is isolated from each other and does not affect each other.


virtualenv can help us solve the problem.
The virtualenvwrapper is a virtualenv package. Easy to create/delete/copy/switch different environments.

Installation and Configuration

Pip Install Virtualenv
Pip Install Virtualenvwrapper

Edit ~/.bashrc Add the following content and source.

export  PYTHON_HOME =/opt/python/ #这里是python的文件夹, please  export  virtualenvwrapper_python= $PYTHON _home /bin/ Python  #所用python解释器  export  virtualenvwrapper_ Virtualenv= $PYTHON _home /bin/virtualenv # The VIRTUALENV program used  if  [-f   $PYTHON _home /bin/virtualenvwrapper.sh]; then .  $PYTHON _home /bin/virtualenvwrapper.sh # After running the virtualenvwrapper.sh, there are some related commands that can be used  fi   

There is also an optional variable workon_home, which tells Virtualenvwrapper which folder to put the virtual environment in, the default is $home/.virtualenvs.

Use

Since it is a management environment. Management management, without creating/deleting/copying/switching these commands.
The main uses are:
mkvirtualenv envname: Create a new virtualenv
Workon envname: Switching environment, Workon without parameters will list all environments
deactive: Exiting the virtual environment
Yes, just remember these commands!

Each virtual environment comes with a PIP and does not have to be installed again. Libraries installed in different environments are isolated from each other.

Virtualenv and Virtualenvwrapper of the standalone Python environment

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.