How to create a virtual environment under Windows (by default)

Source: Internet
Author: User
Tags virtual environment virtualenv

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.


How to create a virtual environment under Windows (by default)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.