Linux command
virtualenv 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Create a virtual environment
virtualenv [venv]
Create with specific Python
virtualenv -p [python3.11] [venv]
Create without pip
virtualenv --no-pip [venv]
Create with system packages
virtualenv --system-site-packages [venv]
Activate the environment
source [venv]/bin/activate
Activate the environment
source [venv]/bin/activate.fish
Deactivate the environment
deactivate
Create with latest seed packages
virtualenv --download [venv]
说明
virtualenv creates isolated Python environments. Each environment has its own Python binary and independent set of installed packages, allowing different projects to have different dependencies without conflicts. When activated, the virtual environment modifies PATH to use the environment's Python and pip, isolating package installations from the system Python. This is essential for reproducible development environments. virtualenv is the original virtual environment tool for Python, predating the built-in venv module. It offers additional features like choosing Python versions and faster environment creation.
参数
- -p _python_, --python= _python_
- Python interpreter to use.
- --system-site-packages
- Give access to system site-packages.
- --no-pip
- Don't install pip.
- --no-setuptools
- Don't install setuptools.
- --no-wheel
- Don't install wheel.
- --download
- Download latest pip/setuptools/wheel.
- --no-download
- Use bundled pip/setuptools/wheel.
- --clear
- Clear existing environment.
- --copies
- Use copies instead of symlinks.
- --prompt _text_
- Custom prompt prefix for the activated environment.
- --activators _list_
- Activators to generate (comma-separated: bash, fish, cshell, powershell, etc.).
- -v, --verbose
- Increase verbosity.
- -q, --quiet
- Decrease verbosity.
FAQ
What is the virtualenv command used for?
virtualenv creates isolated Python environments. Each environment has its own Python binary and independent set of installed packages, allowing different projects to have different dependencies without conflicts. When activated, the virtual environment modifies PATH to use the environment's Python and pip, isolating package installations from the system Python. This is essential for reproducible development environments. virtualenv is the original virtual environment tool for Python, predating the built-in venv module. It offers additional features like choosing Python versions and faster environment creation.
How do I run a basic virtualenv example?
Run `virtualenv [venv]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -p _python_, --python= _python_ do in virtualenv?
Python interpreter to use.