Python2 create a virtual environment and Python3

First, install the windows

1. Install python

Were installed Python2 and Python3

python3.7 default installation directory

C:\Users\Administrator\AppData\Local\Programs\Python\Python37

Installation directory python.exe, pip.py Custom whether to amend

2. Installation and virtualenvwrapper-win virtualenv

pip2 install virtualenv2 -i https://pypi.douban.com/simple
pip3 install virtualenv3 -i https://pypi.douban.com/simple
pip2 install virtualenvwrapper-win -i https://pypi.douban.com/simple
pip3 install virtualenvwrapper-win -i https://pypi.douban.com/simple

 3. Modify the virtual environment

 

------- distinguish between different environments py2 py3 and placed into different workspaces workon folder -----------

 

Python2 and modify the virtual environment script name in the 3 \ scripts were changed to:

(1) virtualenv2 and virtualenv3

 

(2) mkvirtualenv2 and mkvirtualenv3

 

 

 

 

 

 

 

 

note:

34 rows need to change virtualenv2, in order to create not only when the directory is changing, but the use of an interpreter python2

34 rows need to change virtualenv3, in order to create not only when the directory is changing, but the use of an interpreter python3

3) rmvirtualenv2, rmvirtualenv3

 

 

 

 

(4)workon2,workon3

Copy the folder are files workon Py2, and the scripts py3 file workon2, workon3, copy the file open, replace WORKON_H                                                                                                                                                              (. 5) workon                                                                              

 

 

 

 Add workon while viewing path workon2 and workon3 virtual environments

4. Modify the HOME environment variable                                                                                             

 

 Environment variable file folder may be empty file newly created folder # py2 placed under Envs2 folder, py3 on Envs3 folder variable names: WORKON2_HOME variable path: after py2 virtual environment is created where the variable name: WORKON3_HOME variable path: after py3 virtual environment is created where                                                                                                                                                                                                                                                                                                                                                                                                           the new Envs, Envs2, Envs3 folder

 

 -------- does not distinguish between workon2 and workon3, various virtual environments in the same folder --------                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           # py2 and py3 Envs folder on the variable name: WORKON_HOME variable path: after the virtual environment created here

5. distinguish workon2 and workon3 ------------ ---------

1) Create: 

A. fixed position

Creating an environment in D: // envs2, under envs3

mkvirtualenv2/3    #创建不同的Python虚拟环境

Creating an environment in C: \ Users \ Administrator \ Envs under (condition: Create C: \ Users \ Administrator \ Envs directory)

mkvirtualenv

B. arbitrary position

Note: Deleting and switching operation will not take, because without the virtual environment to set an environment variable (not recommended)

virtualenv2/3

(2) switch:   

workon2/3    #进行环境切换,同一个目录下WORKON显示不用切换

(3) Delete:   

 rmvirtualenv2/3    #删除环境

(4) Exit:

 deactivate    #退出环境

(5) Other commands

Do not distinguish py2py3 name- test workon of-Venv # to enter the virtual environment deactive # exit the virtual environment lsvirtualenv # a list of available virtual environment name- mkvirtualenv of-Venv # name- create a virtual environment rmvitualenv of-Venv # delete virtual environment name- cdvirtualenv of-Venv # to enter the virtual environment name- directory cdsitepackages of-Venv # to enter the virtual environment of the site-packages directory name- lssitepackages of-Venv # site-packages directory lists all packages                                                                                                                                                                                                       --------- ------------ does not distinguish between workon2 and workon3                                                                                                                        mkvirtualenv -p C: \ Python36 \ python.exe ENV3 # python3 create a virtual environment                                                    

                     -p C mkvirtualenv: \ Python27 \ python.exe ENV2  # python2 create a virtual environment

Second, install linux

slightly

Reference Documents

1. Create Python2 and Python3 virtual environment virtualenv: https://www.cnblogs.com/tk2049jq/p/7043509.html

2. computer and install Python2 and Python3 virtualenvwrapper: https://www.jianshu.com/p/d22f19496e03

 

Guess you like

Origin www.cnblogs.com/programmer123/p/11685777.html