Setting up my Python development environment on Mac OS X Lion

As I just purchased a new MacBook Air, I wanted to make a clean python development and start using virtualenv. This post shows how I set up my new python development. The system came with Python 2.7 which is what I’ve been using and wanted to keep using — so no need to install another Python version.

First install pip using easy_install.
For some python modules you need the gcc libraries. You can get those by downloading Xcode¬†which has them all included. However, Xcode will take up gigabytes of disk space. So if you don’t plan on using Xcode you can use the OSX GCC installer made by kenne threitz — this is only around 300 MB. After you have installed this, you can for example install ‘pil’ without getting errors.

Next, I installed virtualenv to be able to create different virtual environments to keep my different projects easily seperated.
And after doing this I immediately installed virtualenvwrapper to make it easier to use virtualenv.
To make sure we you can use the virtualenvwrapper commands edit your .bash_profile file. Type: ‘vim .bash_profile’ in your main dir and put in the following (change yourprogrammingdir to the directory of your projects):

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/yourprogrammingdir
source /usr/local/bin/

Save it and source your .bash_profile by: ‘source .bash_profile’.

For now this is what my python development looks like, I’ll update this whenever I add things to it.