2024-07-08
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
venv
OrderIn Python,venv
It is a module for creating and managing virtual environments. Virtual environments can help you isolate different Python packages and dependencies between projects. The following are some commonly usedvenv
Order:
#配置了
python3 -m venv myenv
python -m venv myenv
This will create a new directory calledmyenv
Virtual environment.
On Windows:
./venv/Scripts/activate
On macOS and Linux:
source myenv/bin/activate
After activating the virtual environment, Python commands you run in the terminal will use the Python interpreter and packages in the virtual environment.
Verify that activation is successful
pip list
to see whether the dependency is global or in the current virtual environment.(venv)
Logo.Execute in a virtual environment deactivte
, which will exit the currently activated virtual environment.
pip list
This will list the installed Python packages in the current virtual environment.
pip install package_name
pip install -i https://mirrors.aliyun.com/pypi/simple package_name
This will install the specified Python package in the current virtual environment.
pip freeze