First, install the PYTHON-VIRTUALENV package
sudo apt-get Install virtualenv
After the installation is complete, create a Virtual Environment folder.
mkdir venv
CD venv
Create a virtual environment, pure virtual environment, and the system inside the package without a little contact. Forvirtualenv1.7或者更新版本,这是默认行为。他会在当前目录中创建文件夹env
virtualenv--no-site-packages [Virtual environment name]
#例如env
Virtualenv--no-site-packages Env
To start the virtual environment, you need to activate
SOURCE Env/bin/activate
Notice that the command prompt is changed and has a (venv) prefix that indicates that the current environment is a venv python environment named.
You can install any package via PIP or sudo apt-get install, which is installed in the virtual environment and is not associated with the package in the System file library.
Launch a virtual environment
Deactivate
If you want to delete a virtual environment, simply delete the directory.
RM-RF env
Second, back up the current virtual environment, and store the list of packages needed for the current environment for the next construction of the same environment.
Pip Freeze > Requirements.txt
will produce a file Requirements.txt file.
If you want to build the same environment, just perform
Pip Install-r requirements.txt
Creating a Python virtual environment in UBUNTU14