Python uses virtual environment, python Virtual Environment
Imagine the requirement. To write a series of 1.0 plug-ins used by a project, we need to use 2.0 for a new project. What should we do? Are all updated to version 2.0? In this way, the previous project cannot be maintained.
In this case, we need a virtual environment. Python supports such a plug-in, virtualenv
Install it as follows:
1. pip3 install virtualenv
2. cd A directory for storing virtual environments and creating Virtual Environments
Virtualenv -- no-site-packages venv is the name. You can name it by yourself. 3. activate the virtual environment source venv/bin/activate # source is the environment in linux.
In windows, directly add cd to the scripts directory and execute activate.
The venv here is the name above.
When this format is displayed, it indicates that it is in a virtual environment.
F: \ code library \ Virtual Environment virtualenv \ ven_test \ Scripts> activate (ven_test) F: \ code library \ Virtual Environment virtualenv \ ven_test \ Scripts>
There is no plug-in the environment, because when we create this virtual environment, we select no-site-packages.
Therefore, you need to reinstall all plug-ins.
4. Exit the Virtual Environment
Deactivate
(Ven_test) F: \ code library \ Virtual Environment virtualenv \ ven_test \ Scripts> deactivateF: \ code library \ Virtual Environment virtualenv \ ven_test \ Scripts>
In fact, this function is also encapsulated for us in pycharm.
The following shows how to use the virtual environment in pycharm.
1. Create a virtual environment
Here you can choose whether to inherit the previous version of the plug-in
After confirmation, a virtual environment has been created and applied to our project.
In the project configuration, change the interpreter to the new virtual environment.
This is a new virtual environment. If you want to add an existing environment to pycharm, You need to select this
After that, find python.exe in the scriptsdirectory of the environment to be created, and add it.