How to create a specified virtual environment under Windows

Source: Internet
Author: User
Tags virtual environment virtualenv

A few days ago to share with you how to create a virtual environment by default, no time to get on the car's partner, you can poke this article: How to create a virtual environment under Windows (by default). Today's small series for you to share, how to create a specified Python environment.

To create a virtual environment, you need to use the Virtualenv library, the previous article has been mentioned, here will not repeat it. The default Python interpreter on the computer is the Python3 version, so now you want to create a Python2 version of the virtual environment, in the following way. (PS: First of all to ensure that you have installed Python2 and Python3, will not install Python's small partners can poke this article: Python environment Build-Amway python small white python and Pycharm installation detailed tutorial

1, enter the command line to execute the command "Virtualenv–p C:\Python27\python.exe demo", you can specify the creation of Python2 version of the virtual environment. Where-p means to specify the version of Python, followed by the Python version of the installation path, remember to bring Python.exe. The final demo is the name of the virtual environment.



2. After executing the command, the virtual environment named demo will be created as shown in.



3, the virtual environment will be established by default in the current directory, by looking at the directory can be known, as shown in.



4. To view the Scripts folder, you can see that the Python version is Python2, as shown in.



5. At this point, enter the Activate.bat command at the command line to activate the virtual environment as shown in.



You can see that the demo is already at the front of the path and enclosed in parentheses, indicating that the virtual environment is activated.

6. Enter Python in the Python virtual environment, as shown in the Python version, which you can see is Python2.



7, similarly, if you want to exit the virtual environment, CTRL + Z or exit (), exit Python, and then enter Deactivate.bat on the command line to exit the virtual environment, as shown in.



At this point, the demo folder is gone and the parentheses disappear, indicating a successful exit from the virtual environment.

8, at this time if the new virtual environment in the command line, then the default is Python3 virtual environment, again will not repeat.



In the future, if we want to create a virtual environment, we can switch freely.


How to create a specified virtual environment under Windows

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.