# Twisted Virtual Environment Goodness

January 13, 2009

Python 2.5.1 is bundled into Mac OS X 10.5 (Leopard), which comes also with setuptools. The breadth of easy_install packages is available pretty much at your fingertips on Leopard.

On the downside, Leopard’s python ships with old versions of some packages, and we might need to upgrade them. We are left with three choices:

1. Overwrite packages with new ones.
2. Install new ones and set PythonPath.
3. Use virtualenv.

I prefer to use #3. It’s cleaner, it does not change my system, it allows as many environments as we like without one contaminating the other, while at the same time not requiring a fresh python re-install for every working environment.

I want to create an environment for my imps-to-xmpp gateway, for which will be using twisted words. I want to use the latest version (8.2), but the shipped version with leopard is fairly old (2.5):

$which twistd /usr/bin/twistd$ twistd --version
twistd (the Twisted daemon) 2.5.0
Copyright (c) 2001-2006 Twisted Matrix Laboratories.

$easy_install virtualenv  And now, we’ll create a virtual environment on which we can install the updated twisted: $ cd ~/Sites/
$mkdir python$ cd python
$virtualenv imps$ source imps/bin/activate
$easy_install twisted  We can now check that we are running the latest version of twisted (8.2 as of writing): $ twistd --version
See LICENSE for details.