LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

virtualenvwrapper

Convenience wrappers for virtualenv

TLDR

Create virtual environment
$ mkvirtualenv [envname]
copy
Create with specific Python version
$ mkvirtualenv -p [python3.11] [envname]
copy
Create with packages installed
$ mkvirtualenv -i [package] [envname]
copy
Create from requirements file
$ mkvirtualenv -r [requirements.txt] [envname]
copy
Activate environment
$ workon [envname]
copy
List environments
$ workon
copy
Deactivate
$ deactivate
copy
Remove environment
$ rmvirtualenv [envname]
copy
Copy an environment
$ cpvirtualenv [source] [dest]
copy
Change directory to project
$ cdproject
copy
Run command in all environments
$ allvirtualenv [command]
copy

SYNOPSIS

mkvirtualenv envnameworkon [envname]rmvirtualenv envname

DESCRIPTION

virtualenvwrapper is a set of shell extensions that enhance the standard virtualenv tool for managing Python virtual environments. It provides convenient wrapper commands for creating, activating, switching between, and deleting environments, all from a centralized location rather than scattered across project directories.The core workflow revolves around the `workon` command for listing and switching environments, `mkvirtualenv` for creation, and `rmvirtualenv` for deletion. All environments are stored in a single configurable directory (typically `~/.virtualenvs`), making them easy to find and manage regardless of where project code resides.The tool also supports project directory association, allowing automatic directory changes when activating an environment, and provides hook scripts that run at key lifecycle events such as environment creation, activation, and deactivation for custom automation.

COMMANDS

mkvirtualenv [-a projectpath] [-i package] [-r requirementsfile] envname

Create environment. Options -a, -i, -r are handled by virtualenvwrapper; all other options are passed to virtualenv.
workon [envname]
Activate environment, or list all if no name given.
deactivate
Exit current environment.
rmvirtualenv envname
Delete environment.
cpvirtualenv source dest
Duplicate an existing environment.
cdproject
Change to associated project directory.
setvirtualenvproject [virtualenvpath projectpath]
Associate project directory with environment.
allvirtualenv command
Run a command across all environments.
lsvirtualenv [-b] [-l]
List all environments (-b brief, -l long).

CAVEATS

Requires shell configuration: source the virtualenvwrapper.sh script in your shell profile. All environments are stored in a single directory (default: ~/.virtualenvs), configured by the WORKON_HOME environment variable.

HISTORY

virtualenvwrapper was created by Doug Hellmann to make managing Python virtual environments easier.

SEE ALSO

virtualenv(1), venv(1), pip(1)

Copied to clipboard
Kai