The Magic of Virtualenv

If you've ever done a significant amount of Python coding then you know what a pain it can be to manage modules across different projects. Virtualenv can easily make your life a lot easier.

If you’ve ever done a significant amount of Python coding then you know what a pain it can be to manage modules across different projects. Sometimes it’s even desirable to use specific module versions for certain projects. Virtualenv can easily and swiftly make your life a lot easier.

The most straightforward method for installing virtualenv is to use easy_install

easy_install virtualenv

Next run virtualenv with the name of your project or your test environment

virtualenv test_env
New python executable in test_env/bin/python
Installing setuptools............done.

To start using your new virtualenv source the newly created activate file

$ source test_env/bin/activate
(test_env)$

You can now use pip to install modules in your new virtual environment

(test_env)$ pip install sorl-thumbnail
Downloading/unpacking sorl-thumbnail
Downloading sorl-thumbnail-11.01.tar.gz
Running setup.py egg_info for package sorl-thumbnail
Installing collected packages: sorl-thumbnail
Running setup.py install for sorl-thumbnail
Successfully installed sorl-thumbnail
Cleaning up...

That’s all there is to it. Virtualenv is a great solution for running multiple Python environments on a single system.