Installation

Supported Shells

virtualenvwrapper is a set of shell functions defined in Bourneshell compatible syntax. Its automated tests run under theseshells on OS X and Linux:

• bash
• ksh
• zshIt may work with other shells, so if you find that it does work with ashell not listed here please let me know. If you can modify it towork with another shell without completely rewriting it, then send a pullrequest through the bitbucket project page. If you write a clone towork with an incompatible shell, let me know and I will link to itfrom this page.

Windows Command Prompt

David Marble has ported virtualenvwrapper to Windows batch scripts,which can be run under Microsoft Windows Command Prompt. This is alsoa separately distributed re-implementation. You can downloadvirtualenvwrapper-win from PyPI.

MSYS

It is possible to use virtualenv wrapper under MSYS with a native Windows Pythoninstallation. In order to make it work, you need to define an extraenvironment variable named MSYS_HOME containing the root path tothe MSYS installation.

export WORKON_HOME=$HOME/.virtualenvsexport MSYS_HOME=/c/msys/1.0source /usr/local/bin/virtualenvwrapper.sh or: export WORKON_HOME=$HOME/.virtualenvsexport MSYS_HOME=C:\msys\1.0source /usr/local/bin/virtualenvwrapper.sh

Depending on your MSYS setup, you may need to install the MSYS mktempbinary in the MSYS_HOME/bin folder.

PowerShell

Guillermo López-Anglada has ported virtualenvwrapper to run underMicrosoft’s PowerShell. We have agreed that since it is not compatiblewith the rest of the extensions, and is largely a re-implementation(rather than an adaptation), it should be distributed separately. Youcan download virtualenvwrapper-powershell from PyPI.

Python Versions

virtualenvwrapper is tested under Python 2.7-3.6.

Basic Installation

virtualenvwrapper should be installed into the same globalsite-packages area where virtualenv is installed. You may needadministrative privileges to do that. The easiest way to install itis using pip:

$pip install virtualenvwrapper or: $ sudo pip install virtualenvwrapper

Warning

virtualenv lets you create many different Python environments. Youshould only ever install virtualenv and virtualenvwrapper on yourbase Python installation (i.e. NOT while a virtualenv is active)so that the same release is shared by all Python environments thatdepend on it.

An alternative to installing it into the global site-packages is toadd it to your user local directory(usually ~/.local).

$pip install --user virtualenvwrapper Shell Startup File Add three lines to your shell startup file (.bashrc, .profile,etc.) to set the location where the virtual environments should live,the location of your development project directories, and the locationof the script installed with this package: export WORKON_HOME=$HOME/.virtualenvsexport PROJECT_HOME=$HOME/Develsource /usr/local/bin/virtualenvwrapper.sh After editing it, reload the startup file (e.g., run source~/.bashrc). Lazy Loading An alternative initialization script is provided for loadingvirtualenvwrapper lazily. Instead of sourcing virtualenvwrapper.shdirectly, use virtualenvwrapper_lazy.sh. Ifvirtualenvwrapper.sh is not on your $PATH, setVIRTUALENVWRAPPER_SCRIPT to point to it.

export WORKON_HOME=$HOME/.virtualenvsexport PROJECT_HOME=$HOME/Develexport VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.shsource /usr/local/bin/virtualenvwrapper_lazy.sh

Warning

When the lazy-loading version of the startup script is used,tab-completion of arguments to virtualenvwrapper commands (such asenvironment names) is not enabled until after the first command hasbeen run. For example, tab completion of environments does not workfor the first instance of workon.

Quick-Start

• Run: workon
• A list of environments, empty, is printed.
• Run: mkvirtualenv temp
• A new environment, temp is created and activated.
• Run: workon
• This time, the temp environment is included.

Configuration

virtualenvwrapper can be customized by changing environmentvariables. Set the variables in your shell startup file _before_loading virtualenvwrapper.sh.

Location of Hook Logs

The variable VIRTUALENVWRAPPER_LOG_FILE tells virtualenvwrapperwhere the logs for the hook loader should be written. The default isto not log from the hooks.

Python Interpreter, virtualenv, and $PATH During startup, virtualenvwrapper.sh finds the first pythonand virtualenv programs on the $PATH and remembers them to uselater. This eliminates any conflict as the $PATH changes,enabling interpreters inside virtual environments wherevirtualenvwrapper is not installed or where different versions ofvirtualenv are installed. Because of this behavior, it is importantfor the $PATH to be set before sourcingvirtualenvwrapper.sh. For example:

export PATH=/usr/local/bin:$PATHsource /usr/local/bin/virtualenvwrapper.sh To override the $PATH search, set the variableVIRTUALENVWRAPPERPYTHON to the full path of the interpreter touse and VIRTUALENVWRAPPER_VIRTUALENV to the full path of thevirtualenv binary to use. Both variables _must be set beforesourcing virtualenvwrapper.sh. For example:

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/pythonexport VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenvsource /usr/local/bin/virtualenvwrapper.sh

Default Arguments for virtualenv

If the application identified by VIRTUALENVWRAPPER_VIRTUALENVneeds arguments, they can be set inVIRTUALENVWRAPPER_VIRTUALENV_ARGS. The same variable can be usedto set default arguments to be passed to virtualenv. For example,set the value to —no-site-packages to ensure that all newenvironments are isolated from the system site-packages directory.

export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'

Temporary Files

virtualenvwrapper creates temporary files in \$TMPDIR. If thevariable is not set, it uses /tmp. To change the location oftemporary files just for virtualenvwrapper, setVIRTUALENVWRAPPER_TMPDIR.

Site-wide Configuration

Most UNIX systems include the ability to change the configuration forall users. This typically takes one of two forms: editing theskeleton files for new accounts or editing the global startup filefor a shell.

Editing the skeleton files for new accounts means that each new userwill have their private startup files preconfigured to loadvirtualenvwrapper. They can disable it by commenting out or removingthose lines. Refer to the documentation for the shell and operatingsystem to identify the appropriate file to edit.

Modifying the global startup file for a given shell means that allusers of that shell will have virtualenvwrapper enabled, and theycannot disable it. Refer to the documentation for the shell toidentify the appropriate file to edit.

Version 2.9 includes the features previously delivered separately byvirtualenvwrapper.project. If you have an older verison of theproject extensions installed, remove them before upgrading.
The shell script containing the wrapper functions has been renamed inthe 2.x series to reflect the fact that shells other than bash aresupported. In your startup file, change source/usr/local/bin/virtualenvwrapper_bashrc to source/usr/local/bin/virtualenvwrapper.sh.