Compiling PIL on Ubuntu Natty

Again, I just lost a precious hour trying to install the Python Imaging Library in a virtual environment on Ubuntu. Even though I had installed the required dependencies, the install script did not detect that freetype and zlib were installed... The culprit: Ubuntu installs the libraries in a very weird directory and you need to set these directories in the PIL script.

First, install the required dependencies:

    apt-get install python-dev \
    libfreetype6-dev zlib1g-dev libjpeg8-dev

    tar -xvzf Imaging-1.1.7.tar.gz
    cd Imaging-1.1.7.tar.gz

Then, in the file, set these two variables

    ZLIB_ROOT = ("/usr/lib/i386-linux-gnu", "/usr/include")
    FREETYPE_ROOT = ("/usr/lib/i386-linux-gnu",

Then just run python install when in your virtual environment.