virtualenvwrapper 6.1.2.dev4+g11fdae8¶
virtualenvwrapper is a set of extensions to Ian Bicking’s virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.
Features¶
Organizes all of your virtual environments in one place.
Wrappers for managing your virtual environments (create, delete, copy).
Use a single command to switch between environments.
Tab completion for commands that take a virtual environment as argument.
User-configurable hooks for all operations (see Per-User Customization).
Plugin system for creating more sharable extensions (see Extending Virtualenvwrapper).
Introduction¶
The best way to explain the features virtualenvwrapper gives you is to show it in use.
First, some initialization steps. Most of this only needs to be done
one time. You will want to add the command to source
/usr/local/bin/virtualenvwrapper.sh
to your shell startup file,
changing the path to virtualenvwrapper.sh depending on where it was
installed by pip or your package manager.
$ pip install virtualenvwrapper
...
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv env1
Installing
setuptools..........................................
....................................................
....................................................
...............................done.
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/predeactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postdeactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/preactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postactivate New python executable in env1/bin/python
(env1)$ ls $WORKON_HOME
env1 hook.log
Now we can install some software into the environment.
(env1)$ pip install django
Downloading/unpacking django
Downloading Django-1.1.1.tar.gz (5.6Mb): 5.6Mb downloaded
Running setup.py egg_info for package django
Installing collected packages: django
Running setup.py install for django
changing mode of build/scripts-2.6/django-admin.py from 644 to 755
changing mode of /Users/dhellmann/Envs/env1/bin/django-admin.py to 755
Successfully installed django
We can see the new package with lssitepackages
:
(env1)$ lssitepackages
Django-1.1.1-py2.6.egg-info easy-install.pth
setuptools-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg
django setuptools.pth
Of course we are not limited to a single virtualenv:
(env1)$ ls $WORKON_HOME
env1 hook.log
(env1)$ mkvirtualenv env2
Installing setuptools...............................
....................................................
....................................................
........... ...............................done.
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/predeactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postdeactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/preactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postactivate New python executable in env2/bin/python
(env2)$ ls $WORKON_HOME
env1 env2 hook.log
Switch between environments with workon
:
(env2)$ workon env1
(env1)$ echo $VIRTUAL_ENV
/Users/dhellmann/Envs/env1
(env1)$
The workon
command also includes tab completion for the
environment names, and invokes customization scripts as an environment
is activated or deactivated (see Per-User Customization).
(env1)$ echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate
(env1)$ workon env2
(env2)$ pwd
/Users/dhellmann/Envs/env2
postmkvirtualenv is run when a new environment is created, letting you automatically install commonly-used tools.
(env2)$ echo 'pip install sphinx' >> $WORKON_HOME/postmkvirtualenv
(env3)$ mkvirtualenv env3
New python executable in env3/bin/python
Installing setuptools...............................
....................................................
....................................................
........... ...............................done.
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/predeactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postdeactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/preactivate
virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postactivate
Downloading/unpacking sphinx
Downloading Sphinx-0.6.5.tar.gz (972Kb): 972Kb downloaded
Running setup.py egg_info for package sphinx
no previously-included directories found matching 'doc/_build'
Downloading/unpacking Pygments>=0.8 (from sphinx)
Downloading Pygments-1.3.1.tar.gz (1.1Mb): 1.1Mb downloaded
Running setup.py egg_info for package Pygments
Downloading/unpacking Jinja2>=2.1 (from sphinx)
Downloading Jinja2-2.4.tar.gz (688Kb): 688Kb downloaded
Running setup.py egg_info for package Jinja2
warning: no previously-included files matching '*' found under directory 'docs/_build/doctrees'
Downloading/unpacking docutils>=0.4 (from sphinx)
Downloading docutils-0.6.tar.gz (1.4Mb): 1.4Mb downloaded
Running setup.py egg_info for package docutils
Installing collected packages: docutils, Jinja2, Pygments, sphinx
Running setup.py install for docutils
Running setup.py install for Jinja2
Running setup.py install for Pygments
Running setup.py install for sphinx
no previously-included directories found matching 'doc/_build'
Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin
Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin
Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin
Successfully installed docutils Jinja2 Pygments sphinx (env3)$
(venv3)$ which sphinx-build
/Users/dhellmann/Envs/env3/bin/sphinx-build
Through a combination of the existing functions defined by the core package (see Command Reference), third-party plugins (see Extending Virtualenvwrapper), and user-defined scripts (see Per-User Customization) virtualenvwrapper gives you a wide variety of opportunities to automate repetitive operations.
Details¶
- Installation
- Command Reference
- Customizing Virtualenvwrapper
- Project Management
- Tips and Tricks
- For Developers
- Existing Extensions
- Why virtualenvwrapper is (Mostly) Not Written In Python
- CHANGES
- 6.1.0
- 6.0.0.0a5
- 6.0.0.0a1
- 4.8.4
- 4.8.3
- 4.8.2
- 4.8.1
- 4.8.0
- 4.7.2
- 4.7.0
- 4.6.0
- 4.5.0
- 4.4.1
- 4.3.2
- 4.3.1
- 4.3
- 4.2
- 4.1.1
- 4.1
- 4.0
- 3.7
- 3.6.1
- 3.6
- 3.5
- 3.4
- 3.3
- 3.2
- 3.1
- 3.0.1
- 3.0
- 2.11.1
- 2.11
- 2.10.1
- 2.8
- 2.7.1
- 2.7
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5
- 2.4
- 2.3
- 2.2.2
- 2.2.1
- 2.2
- 2.1.1
- 2.1
- 2.0.2
- 2.0.1
- 2.0
- 1.27
- 1.26
- 1.25
- 1.24.2
- 1.24.1
- 1.24
- 1.23
- 1.22
- 1.21
- 1.20
- 1.19
- 1.18
- 1.17.1
- 1.17
- 1.16
- 1.15
- 1.14
- 1.13
- 1.12
- 1.11
- 1.10
- 1.9
- 1.8.1
- 1.8
- 1.7
- 1.6.1
- 1.3
- 1.0
- Glossary
References¶
virtualenv, from Ian Bicking, is a pre-requisite to using these extensions.
For more details, refer to the column I wrote for the May 2008 issue of Python Magazine: virtualenvwrapper | And Now For Something Completely Different.
Manuel Kaufmann has translated this documentation into Spanish.
Tetsuya Morimoto has translated this documentation into Japanese.
Support¶
Join the virtualenvwrapper Google Group to discuss issues and features.
Report bugs via the bug tracker on GitHub.
Shell Aliases¶
Since virtualenvwrapper is largely a shell script, it uses shell commands for a lot of its actions. If your environment makes heavy use of shell aliases or other customizations, you may encounter issues. Before reporting bugs in the bug tracker, please test without your aliases enabled. If you can identify the alias causing the problem, that will help make virtualenvwrapper more robust.
License¶
Copyright Doug Hellmann, All Rights Reserved
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Doug Hellmann not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.