1. Install the virtual environment
$ sudo easy_install virtualenv
2. Create a virtual environment
$ virtualenv "env_name】
For example:
$ virtualenv Virtualtest
Where--no-site-packages can be used to indicates that the virtual environment does not access the global site-packages. So we can isolate a clean test environment even in systems where we have a large number of development packages installed. can be through check Sys.path or "lib/python2.6/no-global-site-packages.txt" file to determine whether to access Global Site-packages .
$ virtualenv--no-site-packages "env_name】
例如:
$ virtualenv --no-site-packages virtualtest
3. Activating the virtual environment
$ source Virtualtest/bin/activate
4. Verifying the libraries used by the virtual environment
(virtualtest) **:~$ which Python (virtualtest)which Easy_install
5. Quit activating the virtual environment
(virtualtest)**:~$ Deactivate
6. Installing a third-party library in a virtual environment
Pip Install * (here * denotes third-party software library name) *