python virtual environment switching

This paper describes the windowsenvironment, how to create python2and python3virtual working environment. First you need to install on your computer python2as well python3. I installed python27and python36. And environment variables default configuration is python36.

Install virtual components

Next, you need to install virtualenvor windowsunder virtualenvwrapperwhich a package is on the former, more convenient to use.

windowsYou can use the following command at

pip install virtualenvwrapper-win

linuxYou can use the following command at

pip install virtualenv

Create a virtual machine environment

By default, in windows, you can create a virtual machine environment using the following command:

mkvirtualenv test

linuxUnder the direct use:

virtualenv test

It should be noted that the above command when you create a virtual machine environment, based on the current environment, the default is pythonto create a version, that is, if the current environment is to use the default python3, create a virtual environment, the default pythonversion will be python3.

Create a virtual environment based on python version

When you create a virtual environment, you need to specify pythonthe program location, such as windowsunder:

mkvirtualenv -p d:\app\Python27\python.exe test

Similarly, in the linuxcase:

virtualenv -p /xx/xx/python test

Enter the virtual environment

In the windowscase, use the following command to enter the virtual environment:

workon test

Note that in the windowsenvironment, the virtual environment is installed in the default C:/用户/xxx/Envsdirectory, that user space.
Exit the virtual environment:

deactivate

To delete a virtual environment:

rmvirtualenv test

Reproduced in: https: //www.jianshu.com/p/92bee56d3a12

Guess you like

Origin blog.csdn.net/weixin_33834075/article/details/91273744
Recommended