Why is virtualenv so great?

It just is. Read the virtualenv documentation.
If you’re a Python developer you need virtualenv in your life. You also need
virtualenvwrapper too.

virtualenvwrapper is a set of extensions to Ian Bicking’s virtualenv tool
for creating isolated Python development environments.

Installing Python and virtualenvwrapper

Outlined below is how I install Python and virtualenvwrapper. We have not
yet made the jump to Python 3 at work, hence the references to Python 2.6 and
2.7. Some of us develop on Arch Linux, but all deployments are on Ubuntu.

Arch Linux

As Arch Linux is a rolling release we can simply install everything via
pacman.

Creating a virtualenv

Open a new shell to ensure that the virtualenvwrapper configuration is active.

The following will create a new virtualenv called Nikola5 based on Python
2.7 and will not give access to the global site-packages directory.

mkvirtualenv -p python2.7 --no-site-packages ~/Snakepit/Nikola5

mkvirtualenv_help shows a full list of arguments, the -r switch can install
all the packages listed in a pip requirements file into the newly created
virtualenv. Very useful.

Working on a virtualenv

To workon, or activate, an existing virtualenv do the following.

workon Nikola5

You can switch to another virtualenv at any time, just use workon envname.
Your shell prompt will change while a virtualenv is being worked on to indicate
which virtualenv is currently active.

While working on a virtualenv you can pip install what you need or manually
install any Python libraries safe in the knowledge you will not adversely
damage any other virtualenvs or the global packages in the process. Very useful
for developing a new branch which may have different library requirements than
the master/head.

When you are finished working in a virtualenv you can deactivate it by simply executing: