Virtualenv with Virtualenvwrapper Debian

Virtualenv is usefull to create isolated environments for Python projects.

Install pip

sudo apt-get install python-pip

Install virtualenv

sudo pip install virtualenv

Create a dir to store your virtualenvs

mkdir ~/.virtualenvs

At this point you are all set to use virtualenv with the standard commands. However, I prefer to use the extra commands included in virtualenvwrapper. Lets set that up.

Install virtualenvwrapper

sudo pip install virtualenvwrapper

Set WORKON_HOME to your virtualenv dir

export WORKON_HOME=~/.virtualenvs

Add to .bashrc

Execute this script:

. /usr/local/bin/

Exit and re-open your shell, or reload .bashrc with the command . .bashrc and you’re ready to go.

Create a new virtualenv

mkvirtualenv myawesomeproject

to exit your new virtualenv, use deactivate.

Switch between enviornments with workon

To load or switch between virtualenvs, use the workon command:

workon myawesomeproject

You can read more about virtualenv here and virtualenvwrapper here. You might also want to look at this very similar (and probably better) python guide post.