Working with virtualenvs using virtualenvwrapper

Check out the new site at

virtualenvwrapper is a virtualenv wrapper that makes it easier to navigate and manage multiple envs. When you are working on different projects they all need their own virtualnenvs as they require different versions of the same dependencies if not more. To work with multiple envs the virtualenvwrapper comes in handy.

Instalation and configuration

The documentation covers all, but it's easy to install and use this application. Installation (in the system) is typical:

pip install virtualenvwrapper
Next we have to specify a path to a folder that will contain all virtualenvs:
export WORKON_HOME=~/Envs
mkdir -p $WORKON_HOME
source /usr/local/bin/

Of course the folder set under WORKON_HOME may be different than in that example. When this configuration is done you may start using the wrapper. To save the settings between reboots you can put it into your .bash_profile or .bashrc file (except mkdir).

How to use it

You create envs via the standard:

mkvirtualenv VIRTUALENV_NAME
Now to start working on a given virutalenv you may use the wrapper:
If you would want to go to site_packages of the env just use:
If you would want to jump to the project folder then you need to use an extra script called cddev-create. Execute it when in the destination folder. It will save the path and allow you to jump to it with cddev:
cd ~/projects/my_django_app
You need to install virtualenvwrapper inside the virtualenv too in order for this to work.
Next time when you open a console/terminal, workon on your env you will be able to execute:
And after that you will end up in ~/projects/my_django_app. You can also use builtin cdproject and few other helpers.

Python programming, 16 June 2013

Check out the new site at
Comment article
Comment article RkBlog main page Search RSS Contact