virtualenv is used to create multiple standalone Python runtime environments on a single machine, which resolves:
1. Third-party package dependencies between quarantined items
2. Install a new Python package without permission
In addition, there is an additional benefit: when deploying an application, package the virtual environment of the development environment into a production environment.
1. Installation
C:\python27>pip Install Virtualenv
1. Role
D:\mysite>c:\python27\scripts\virtualenv.exe env_py27
The above code installs the ENV_PY27 environment directory in the D:\mysite directory with its file structure:
Directory of D:\mysite\env_py272018/ to/ - .: .<DIR> .2018/ to/ - .: .<DIR> ..2018/ to/ - .: .<DIR>Include2018/ to/ - .: .<DIR>Lib2018/ to/ - .: .<DIR> Scripts
Where lib/site-packages contains the libraries that are installed from the system under PYTHON27. By default, the virtual environment relies on site packages in the system environment, which means that the third-party package that is already installed in the system is installed in the virtual environment, and if you do not want to rely on the package, you can add parameters- No-site-packages setting up a virtual environment
Virtualenv--no-site---no-site-packages env_py27
3. Enabling the Virtual environment
D:\mysite\env_py27>scripts\activate
4. Deactivate a virtual environment
D:\mysite\env_py27>scripts\deactivate
Python Virtual Environment virtualenv