Reference website: https://realpython.com/python-virtual-environments-a-primer/
First, create a new virtual environment
2:virtualenv my_new_virtualenv3. Python3 already have the Venv module from the standard library installedpython3-m venv my_new_virtualenv
Or
Virtualenv-p $ (which Python3) my_new_virtualenv
Start the virtual environment
CD .../python-virtual-environmentssource my_new_virtualenv/bin/activate
Turn off the virtual environment
Deactivate
Second, the virtual environment working principle
This section may refer to the following sections of the above Web site,
How Does a Virtual environment work?
The most important of these is that, in both environments, the Python executables store location $which python and environment variable $path $echo $PATH Different.
Iii. Virtualenvwrapper-Tools for managing multiple virtual environments
When we create multiple virtual environments, there are a lot of problems around how to manage these virtual environments, so Python provides a toolkit virtualenvwrapper for managing multiple virtual environments. A few useful features of the toolkit are listed below, please refer to the above website for details.
- Organizes all of your virtual environments on one location
- Provides methods to help you easily create, delete, and copy environments
- Provides a single command to switch between environments
Introduction to Python Virtual environment virtualenv