virtualenv virtual environments and introduce

First, why use a virtual environment virtualenv

  • Depend in each virtual environment independent of each other, a different set of items may be used alone python environment, to reduce the impact of the respective dependencies
  • Easier to deploy
  • Containerized

Two, virtualenv create a virtual environment

Third, why create a virtual environment using virtrualenvwrapper

  • Convenient and efficient to create a separate virtual Python development environment
  • Virtualenv are extensions, including functions virtualenv
  • Create a virtual environment more convenient unified management than virtrualenv

The use of virtual environments virtualenvwrapper

1, the installation virtualenvwrapper

Install window environment

pip install virtualenvwrapper-win

Installation under Linux / MacOS environment

pip install virtrualenvwrapper

2, virtualenvwrapper basic use

(1) to create a virtual environment

mkvirtualenv xxxmy_env [virtual environment project name]

Note: The project mkvirtualenv created by default stored in the current user / Env directory systems, such as: window system, located in the C: / Users / current user / Env directory

(2) other context switching

workon my_env [need to switch to a virtual environment project name]

C:\Users\Administrator>workon

Pass a name to activate one of the following virtualenvs:
==============================================================================
slyangEnv
slyangEnv2

(3) to exit the current virtual environment

deactivate

(4) remove a virtual environment

rmvirtualenv my_env

(5) List all virtual environments

livirtualenv

(6) to the directory where the virtual environment

cdvirtualenv

(7) Modify the default virtual environment management path
Step 1: System Settings> Environment Variables> in the Path environment variable, add WORK_HOME variables, fill out the address for the directory file folder unified management of virtual environments
WORK_HOME = C: / ENV
every time mkvirtualenv my_env generated by the project will be stored in C: / ENV / my_env in

(8) to create a virtual environment when designated python version

mkvirtualenv --python == C: \ Python36 \ python.exe my_env [ virtual environment project name]
Results: my_env virtual environment directory, python36 version of

Guess you like

Origin www.cnblogs.com/yangsun/p/11735792.html