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 setup.py 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 vim setup.py
Then, in the setup.py file, set these two variables
ZLIB_ROOT = ("/usr/lib/i386-linux-gnu", "/usr/include") FREETYPE_ROOT = ("/usr/lib/i386-linux-gnu", "/usr/include/freetype2/freetype")
Then just run python setup.py install when in your virtual environment.