What Virtualenv is. Virtualenv is a tool to create isolated Python environments. In order to isolate different versions of the development environment (if the project is collaborative development, the version of the library problem is a headache, with this can be in their own environment to run).
Step one, install Virtualenv: (PIP installation refer to Python third Party Library series 25--pip Library)
$ pip Install virtualenv
//or by using sudo temporary elevation privileges for permissions issues
$ sudo pip install virtualenv
Step two, and then run the command virtualenv
$ virtualenv ENV //env is the name of this isolated environment
installing Setuptools......done
installing Pip...................done
$cd env
$ls
bin include Lib local //You can see that these four directories are created in the Env isolation environment.
Here are the next few important subdirectories:
Env/lib/pythonx.x/site-packages: All libraries installed in an isolated environment are installed in this directory
The operating environment of the Env/bin/python:python parser
Step three, enter the isolated environment
into the environment in other words is said: Change the shell environment variable $path
Xxx@xxx:~/env$source/bin/activate
(ENV) xxx@xxx:~/env$
You'll find out more here (ENV), which means you're already in an isolated environment, and you want to exit the environment with the Deactivate command.
The environment between activate and deactivate is to isolate the environment, and all of the operations you want to isolate are between these two commands.
Step four, use the PIP command
$pip Freeze > Requirements.txt//Save package dependency information in Requirements.txt file
$pip install-r requirements.txt// The PIP automatically downloads and installs all the packages in the file from the Web.
$pip Install somepackage==1.0//install a software called Somepackage, version 1.0
$pip Uninstall somepackage/Uninstall Somepackage