Many small partners usually use Python, some projects need to use Python2 to develop, and some projects need Python3 to develop. When it is unclear how to separate the environment, at this time the two environments began to fight, each other silly points are not clear. Virtual environment as a weapon of isolation came into being, in fact, the greatest advantage of virtual environment is to isolate our development environment, so that each other unaffected. Today, the small series to give you a brief introduction of how to create a virtual environment under Windows, the specific tutorial is as follows.
1, the virtual environment needs to use the library is virtualenv, need to use the installation command PIP install virtualenv to install, as shown in. Of course, the small part of this has been installed before, so when the installation of the hint that the library already exists.
2, after the installation is complete, you can create the virtual environment directly, using the command "virtualenv test" to create, where test is the name of the virtual environment, you can customize the settings. For a moment, the virtual environment will be created automatically, as shown in.
3, the environment will be created by default in the current directory, here, the current directory is C:userslenovo, into the directory, you can see the test virtual environment has been created, as shown in.
4, of course, can also be viewed through the command Line window, as shown in.
5. Continue to open the Scripts folder, you can see the Python file as shown in.
6, here we can see there is a Activate.bat file, indicating the activation of the virtual environment. You can activate the Python virtual environment by entering the Activate.bat command directly in this directory, as shown in.
At this point, you can see the test folder at the top, and a few more parentheses, this means that we have successfully entered the virtual environment.
7, enter Python in the virtual environment, you can see the version of Python, as shown, this is the PYTHON3 environment.
8, if you want to quit Python, you can use the command exit () or shortcut key Ctrl + Z, to exit, as shown in. If you want to exit the Python virtual environment, enter the command Deactivate.bat in the current directory, as shown, the front test is gone, and the brackets disappear, indicating that you have exited the virtual environment.
9, where the Python environment is set by default to Python3 version, if you want to create a Python2 version of the virtual environment, how to create it? Please look forward to the next article.
Life is short, I use python~~
How to create a virtual environment under Windows (by default)