Registry / devops / virtualenv

virtualenv

JSON →
library21.2.0pypypiunverified

virtualenv is a tool for creating isolated Python environments, allowing developers to manage dependencies for different projects separately. The current version is 21.2.0, with regular updates to enhance functionality and maintain compatibility with Python versions.

pip install virtualenv
INSTALL
IMPORT
SIG · VIRTUALENV
V
virtualenv
devopspythonv21.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

This script demonstrates how to create, activate, use, and deactivate a virtual environment using virtualenv.

import os # Create a virtual environment os.system('virtualenv myenv') # Activate the virtual environment if os.name == 'nt': os.system('.\\myenv\\Scripts\\activate') else: os.system('source myenv/bin/activate') # Install a package within the virtual environment os.system('pip install requests') # Deactivate the virtual environment os.system('deactivate')
virtualenv --version
Debug
Known issues
breakingvirtualenv 21.0.0 refactored the discovery module, which may affect custom scripts relying on internal APIs.
fix
Review and update custom scripts to align with the new discovery module structure.
affects: 21.0.0 and later
deprecatedThe --relocatable option is experimental and may not work in all circumstances.
fix
Avoid using the --relocatable option; consider other methods for creating portable environments.
affects: All versions
gotchaCreating a virtual environment without specifying the Python version may result in using an unintended interpreter.
fix
Use the -p option to specify the desired Python interpreter when creating a virtual environment.
affects: All versions
gotchaSystem-wide PYTHONPATH settings can interfere with virtualenv's isolation.
fix
Ensure PYTHONPATH is unset or correctly configured when working within a virtual environment.
affects: All versions
gotchaMoving a virtual environment directory can break its functionality due to absolute paths.
fix
Recreate the virtual environment in the new location instead of moving it.
affects: All versions
gotchaActivation or deactivation of the virtual environment fails with 'sh: 1: source: not found' or 'sh: 1: deactivate: not found' errors, indicating that the shell's `source` command is not available or the activation script cannot be found in the current shell environment (e.g., when using a minimal shell like dash without sourcing capabilities).
fix
Ensure that the shell executing the activation command supports `source` (e.g., Bash, Zsh). If a minimal shell is used, consider explicitly calling the Python interpreter from the virtual environment's `bin` directory (e.g., `/path/to/venv/bin/python`) or ensure the `PATH` is correctly updated manually, or switch to a compatible shell for activation.
affects: All versions
gotchaThe 'deactivate' command was not found or could not be executed by the shell. This can occur if the virtual environment's activation script was not properly sourced, or if the 'deactivate' script is missing or corrupted.
fix
Ensure the virtual environment is correctly activated using 'source /path/to/venv/bin/activate'. If the issue persists, verify the integrity of the 'deactivate' script within the virtual environment's 'bin' directory or recreate the virtual environment.
affects: All versions
Errors
Common errors & fixes
virtualenv: command not found
The `virtualenv` command is not installed, or its executable location is not included in your system's PATH environment variable.
fix
Install virtualenv globally using pip: `pip install virtualenv`.
failed to create virtual environment
The virtual environment could not be created because the target directory does not exist or the user lacks write permissions for that location.
fix
Ensure the parent directory exists and you have write permissions, or specify a different path: `mkdir my_project && cd my_project && virtualenv venv`.
Cannot find python interpreter
`virtualenv` could not automatically locate a Python executable at common system paths.
fix
Specify the full path to your desired Python interpreter using the `-p` flag: `virtualenv -p /usr/bin/python3.9 my_env`.
'activate' is not recognized as an internal or external command, operable program or batch file.
On Windows, the virtual environment activation script needs to be run by specifying its full path and correct file extension, typically from the `Scripts` directory.
fix
In Command Prompt, use: `.\my_env\Scripts\activate.bat`. In PowerShell, use: `.\my_env\Scripts\Activate.ps1`.
Upgrade
Version history
21.2.0latest on PyPI · released Mar 9, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
16
Resources
virtualenv — pip install virtualenv · libregistry