[python] How to create a virtual environment (windows)

1. How to create a virtual environment under the python project:

There are two ways to create a virtual environment folder. For example, my virtual environment folder is python_ven_demo:

1. Create directly under the folder: (Windows)

First create a new folder python_ven_demo,
then enter the folder cd python_ven_demo,
and then build a virtual environment: python -m venv . (Note: add a space after venv with a little ".")

2. Command line mode:

Create a virtual environment folder and virtual environment directly in the current directory:
directly enter python -m venv python_ven_demo (virtual environment folder name, create a folder directly in the current directory, and generate a virtual environment at the same time)
insert image description here

3. Activate into the virtual environment:

You need to cd to the Sripts directory and execute the activate command to enter:
insert image description here

4. Install the plugin in the virtual environment:

Note: Only after activating the virtual environment - installing the plug-in can it be isolated from the global environment, otherwise the virtual environment will become a decoration. The virtual environment
insert image description here
and the global environment will be isolated at this time. You can install different plug-ins in different environments:

5. View the version number of the installed plugin:

insert image description here

6. Exit the virtual environment:

insert image description here

2. Under Mac and Linux:

The steps are the same. The activation method needs to be in the bin directory: use the source activate command to activate:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_52358204/article/details/125410560