Common command python virtual environment

Original: https://www.jianshu.com/p/d8833799d934

 

When doing a project, you may use some of the modules, are used if the computer comes with python environment, and all the modules are installed in it, so that comes easily python environment is very bloated, and that time if you migrate to another the computer will also be required to re-install the corresponding module, so you can use the virtual environment, install the corresponding module in a different environment, migration also migrates to the environment in the past

Use virtual environment

step

1. Create a virtual environment
enter the command: virtualenv 环境名
(If you have multiple python versions can be ordered: to create a virtual environment) virtualenv -p python路径 环境名
2. Enter in the environment Scriptsfolder
enter the command to execute the script: activate
3. Then you can in the virtual environment under pip installation package or do a variety of things, such as to install django2.0 version you can:pip install django==2.0

Exit Virtual Environment

input the command:deactivate

Management of virtual environments

Virtual environments can also be managed through a number of tools to use more convenient, it is recommended virtualenvwrapper
enter the command: pip install virtualenvwrapper-win(window version) , Downloadvirtualenvwrapper

Create a virtual environment

Enter the command: mkvirtualenv 环境名
creating directly virtualenv difference is that the front that is created under the current folder a virtual environment, and this is the unity of the current user envsto create a folder and will automatically enter into this virtual environment
If you do not want to default create a local ( c:\user\envs), you can create a new environment variables: WORKON_HOME, and then set the default path inside
if you want to specify python version, enter:mkvirtualenv --python=python路径(到exe文件) 环境名

Enter the virtual environment

input the command:workon 环境名

Exit Virtual Environment

input the command:deactivate

Delete the virtual environment

input the command:rmvirtualenv 环境名

Lists the virtual environment

input the command:lsvirtualenv

Into the virtual environment directory

input the command:cdvirtualenv 环境名

More Reference

https://www.cnblogs.com/codechangemyworld/p/5277032.html
https://www.cnblogs.com/chenxinming-top/p/7843178.html

 

Guess you like

Origin www.cnblogs.com/heymonkey/p/11762866.html