Amazon Web Services logo

In this post we are going to look at using virtualenvwrapper in conjunction with virtualenv.

First, install it

sudo `which pip` install virtualenvwrapper

and add the line

source /usr/local/bin/virtualenvwrapper.sh

to .bash_profile.

Restart the shell

exec bash -l

One of the benefits of using virtualenvwrapper is that it makes it easier to create virtual environments. From

virtualenvwrapper --help

we have

mkvirtualenv: Create a new virtualenv in $WORKON_HOME

Next,

$WORKON_HOME 

needs to be set in .bash_profile, e.g. by adding

export WORKON_HOME=~/.virtualenvs

To test, the most common commands are

workon

which returns a list of all virtual environments, as does

lsvirtualenv

Other common commands are

mkvirtualenv venv1
deactivate
rmvirtualenv venv1

(when a new virtual environment is created, it is automatically activated, and an environment cannot be deleted whilst activated).