Using Python virtual environment

1 Install the virtualenv 
PIP3 the install the virtualenv

 2 . Create a directory 
mkdir Myproject 
CD Myproject
 3. create separate execution environment - naming 
the virtualenv --no-Site-to python3 Venv Packages - Python = # give environment independent third party package and specify the interpreter is python3 
4 . enter the virtual environment 
Source Venv / bin / of an activate # this time into the virtual environment (Venv) Myproject 
5 to install third-party packages. 
(Venv) Myproject: PIP3 install Django == 1.9.8
 # At this point the package will be installed pip to the next venv environment, venv is created for Myproject 
6 exit venv environment 
deactivate command
 7 . 
how virtualenv is to create "independent" of the Python runtime environment it? The principle is very simple, is to copy the system to virtualenv Python environment, use the command source venvWhen / bin / activate a virtualenv into the environment, virtualenv will modify environment variables, so the command python and virtualenv pip point to the current environment.

 

1. Create a virtual environment: 
$ mkvirtualenv my_django115 
This creates my_django115 folders in ~ / Envs in. 

2. Work on the virtual environment: activate the virtual environment my_django115 
$ workon my_django115 

3. then create a new virtual environment 
$ mkvirtualenv my_django2 

virtualenvwrapper provide the name of the environment tab completion. 
When there are many environmental and difficult to remember their names, which appear to be very useful. 

4. workon can also stop any of your current environment, you can switch back and forth multiple virtual environments 
workon django1.15 
workon django2.0 

5. You can also manually stop the virtual environment 
deactivate 

6. To delete a virtual environment, you need to exit the virtual environment 
rmvirtualenv my_django115

 

Guess you like

Origin www.cnblogs.com/kaishirenshi/p/11751738.html