Reverse Engineeringpythonvirtualenvenvironmentisolationdevelopment

Python Virtual Environment Creator

virtualenv creates isolated Python environments, each with its own Python executable and independent set of modules installable via pip. Virtual environments can be created without root access.

Description

virtualenv is a tool to create isolated Python environments, enabling developers to work with different sets of Python modules without conflicts. Each virtual environment operates independently with its own Python executable and pip-installed packages. This isolation is particularly useful for projects requiring specific package versions or testing different Python configurations.

Unlike the built-in venv module (available since Python 3.3), virtualenv offers superior performance through app-data seed methods, greater extensibility, support for arbitrarily installed Python versions with automatic discovery, and a richer programmatic API. The tool includes a command-line script for easy environment creation and management.

Virtual Python instances created by virtualenv do not require root privileges, making it ideal for multi-user systems or restricted environments. The python3-virtualenv package provides the core functionality, while the virtualenv dependency package serves as a meta-package.

How It Works

virtualenv creates isolated Python environments by copying or symlinking the Python interpreter and establishing separate site-packages directories. It uses a creator mechanism (builtin, cpython3-posix, or venv) to construct the environment structure in the specified destination directory. Seeders (app-data or pip) populate the environment with essential packages like pip and setuptools using cached wheels or PyPI downloads. The tool discovers target Python interpreters via builtin discovery, supporting version specifiers and custom interpreter paths. Activation scripts for various shells (bash, fish, powershell, etc.) modify the shell environment to use the virtual environment's Python executable and paths.

Installation

bash
sudo apt install python3-virtualenv

Flags

--versiondisplay the version of the virtualenv package and its location, then exit
--with-tracebackon failure also display the stacktrace internals of virtualenv (default: False)
--read-only-app-datause app data folder in read-only mode (write operations will fail with error) (default: False)
--app-data APP_DATAa data folder used as cache by the virtualenv (default: /root/.cache/virtualenv)
--reset-app-datastart with empty app data folder (default: False)
--upgrade-embed-wheelstrigger a manual update of the embedded wheels (default: False)
-v, --verboseincrease verbosity (default: 2)
-q, --quietdecrease verbosity (default: 0)
--discovery {builtin}interpreter discovery method (default: builtin)
-p, --python pyinterpreter based on what to create environment (path/identifier/version-specifier)
--creator {builtin,cpython3-posix,venv}create environment via (builtin = cpython3-posix) (default: builtin)
--clearremove the destination directory if exist before starting (will overwrite files otherwise) (default: False)
--no-vcs-ignoredon't create VCS ignore directive in the destination directory (default: False)
--system-site-packagesgive the virtual environment access to the system site-packages dir (default: False)
--symlinkstry to use symlinks rather than copies, when symlinks are not the default for the platform (default: True)
--copies, --always-copytry to use copies rather than symlinks, even when symlinks are the default for the platform (default: False)
--seeder {app-data,pip}seed packages install method (default: app-data)
--no-seed, --without-pipdo not install seed packages (default: False)
--activators comma_sep_listactivators to generate - default is all supported (default: bash,cshell,fish,nushell,powershell,python)
--prompt promptprovides an alternative prompt prefix for this environment (value of . means name of the current working directory)

Examples

Display the full help message and usage information for virtualenv
virtualenv -h
Create a new virtual environment in the specified directory using default settings
virtualenv /path/to/myenv
Create a virtual environment using a specific Python 3.11 interpreter
virtualenv -p python3.11 myproject
Create a virtual environment with access to the system site-packages directory
virtualenv --system-site-packages shared_env
Create a bare virtual environment without installing pip or setuptools seed packages
virtualenv --no-pip --no-setuptools bare_env
Create environment using venv creator and pip seeder method
virtualenv --creator=venv --seeder=pip myvenv
Recreate an existing environment using symlinks and clear previous contents
virtualenv --symlinks --clear existing_env
Updated 2026-04-16kali.org ↗