Introduction to Virtualenv and Virtualenvwrapper
The Virtualenv tool can create isolated python environments
We often encounter two FAQ versions that rely on the indirect license
Version dependencies:
1. If you have an app that requires a library of Libfoo 1.0, and another app that requires Libfoo 2.0 libraries, how can you install both libraries to/usr/lib/python2.7/site-packages?
2. When the library of the system has changed, perhaps the app can not run
Indirect license
3. When the host, we do not have root permissions.
Virtualenv can solve such a problem, it will create a separate environment, the library will be installed in its own directory, will not be shared with other environments.
Because Virtualenv is a bit troublesome to use, wrapper encapsulates it to make it better, and eventually we use the wrapper-provided command, but the actual work is done by virtualenv. installation
It is recommended to use PIP installation
Pip Install virutalenv Virtualenvwrapper
virtualenv Usage
Creating an environment
virtualenv [Virtual Environment name]
virtualenv test
The default created environment is that you can use a package that the system has installed.
If you do not want to use the system's package, plus the –no-site-packeages parameter
Virtualenv--no-site-packages Test
This time will create the directory test activation Environment
CD test
source./bin/activate
At this point, you are entering an isolated environment where the installation, uninstallation, and use of modules will be in the test environment without affecting the system and other environments. Exit Environment
Deactive
the use of Virtualenvwrapper
We can see that the created environment is fragmented, and that the CD is executed and the source is executed to activate the environment.
VW can manage the environment, record the created environment and manage it. Initialization of
After the first installation is complete, you need to set a variable workon_home, which will be used as a prefix for all environments and source/usr/local/bin/virtualenvwrapper.sh
$ mkdir-p $WORKON _home
$ export Workon_home=~/envs
$ source/usr/local/bin/virtualenvwrapper.sh
By adding the Export command and Source command to ~/.bash_profile, you do not have to repeat the initialization of the create environment
Mkvirtualenv env1
mkvirtualenv env2
After the environment is created, it automatically enters the directory and activates the environment. Switching Environments
Workon env1
Workon env2
List Existing Environment
Workon
Exit Environment
Deactivate
Delete Environment
Rmvirtualenv
Create Project
The project will be created into the Project_home directory, which is actually equivalent to building an environment under a directory.
Mkproject
Reference
http://liuzhijun.iteye.com/blog/1872241
http://virtualenvwrapper.readthedocs.org/en/latest/
http://www.virtualenv.org/en/latest/