Motivation

Creating a slightly different environment

Say that we have written an app for Django v1.5.1 and want to check that it is compatible with an earlier version of Django, e.g., v1.4.1. With Virtualenv this is very easy. All we need to do is deactivating the current virtual environment and create a new one where we install Django v1.4.1. Deactivation of an environment is done by the command deactivate:

(venv)Terminal> deactivate
Terminal>

Observe that deactivation removes the prompt prefix (venv). To re-activate, just run source bin/activate.

With the same procedure as before we create a new virtual environment, now called venv2, and source its activate file. This time we install a specific Django version:

Terminal> virtualenv venv2
Terminal> cd venv2
Terminal> source bin/activate
(venv2)Terminal> pip install yolk Django==1.4.1

As always, yolk is our tool to assure that the correct version a software is installed:

(venv2)Terminal> yolk -l | grep Django
Django          - 1.4.1        - active

Now we have two Python environments, venv with Django 1.5.1 and venv2 with Django 1.4.1. This makes it easy to test how the same app behaves on different versions of Django without making any changes to the system's configuration. Just copy the files for the app to a directory in the virtual environment and run.