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