It seems like many people install PIL in Snow Leopard but the installed library can't open any Jpeg file. Today I try to fix that problem in a Macbook that just upgraded its OS to Snow Leopard (so we have to install everything again).
First, I found that the Macbook owner already install libjpeg via fink (http://www.finkproject.org/). Unfortunately, libjpeg in fink was pre-compiled without --enable-static which required by PIL.
So, my solution is so simple. I just uninstall the libjpeg that came with fink by:
$ sudo apt-get uninstall libjpeg-shlibs
If you already installed other packages that require libjpeg and libjpeg-shlibs they will be removed also. However, if you really need a functioning PIL, you have to do this.
Next, I download libjpeg latest version (http://www.ijg.org/files/jpegsrc.v7.tar.gz), untar it, and configure it:
$ tar zxvf jpegsrc.v7.tar.gz $ cd jpeg-7 $ ./configure --enable-shared --enable-static $ make $ sudo make install
Now, you just installed libjpeg into /usr/local/lib. So, it's time to install PIL. Download the PIL source code from http://effbot.org/downloads/Imaging-1.1.6.tar.gz then untar it:
$ tar zxvf Imaging-1.1.6.tar.gz $ cd Imaging-1.1.6
This is the trick, you must open setup.py with your prefered text editor then looking for the line JPEG_ROOT = None and then it to JPEG_ROOT = libinclude("/usr/local") then save the file and continue:
$ python setup.py build
If everything fine, you can install PIL to your system library. If the PIL need something that didn't exist, it will tell you on the error message. You may install the missing library via fink or download and compile it by yourself. Then install the PIL as root:
$ sudo python setup.py install --optimize=1