Install libjpeg and PIL on OS X Leopard

You will need these if you're working with ImageFields in Django.

I have been building my first site using the Python-based development framework Django and it is really fantastic! I am picking up some of it very fast (the concept of templates and template tags, for example) because of my experience with the PHP-based CMS ExpressionEngine, and some of it is totally foreign to me... but as I muddle through it, I can tell that I've begun to learn some very powerful tools, especially once I got Django working with the jQuery javascript library.

When working with images such as profile avatars, you need to have the Python Imaging Library installed, which also means installing the libjpeg library to compile PIL. I found a couple articles here and here but it seemed that only part of each worked for me. Last night I installed everything again on my PowerBook running Mac OS X Leopard 10.5.4, so I recorded the combination that worked for me:

1. If you haven't already, you must install the Apple Development Tools (XCode).
2. Download and install the Unix software installer Fink. The binary installers for the Mac worked great, both on my Intel and PowerPC machines.
3. Open a Terminal window and type:

  1. fink install libjpeg
  2. curl -O http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz
  3. tar -xzf Imaging-1.1.6.tar.gz
  4. cd Imaging-1.1.6
  5. sudo python setup.py install
And that's it!

Posted on July 9, 2008, 10:41 p.m. Tags: leopard libjpeg osx pil python

Comments

  • Hi There,
    If you do not use "fink" for whatever reason, and use "maport" instead, then do the following:
    port install gd2

    The gd2 would install a number of the graphics lib, including libjpeg and libpng. you will find them in /opt/local/lib

    Posted by: Fawzi on Dec. 31, 2008 Reply

  • Oh man! thanks so much for posting this. I was about to tear my hair out. FYI, I've tested these exact instructions with 10.6 (snow leopard) and they work flawlessly there as well.

    I was trying to manually install libjpeg, then manually install Imaging-1.1.6 ... apparently fink knows something about OS X's library paths that configure doesn't...

    Posted by: James on Sept. 13, 2009 Reply

  • Thank you so much for this. I spent over 2 hours trying to get these two to install on my mac to no avail but your instructions worked flawlessly :)

    G

    Posted by: GP on Dec. 30, 2008 Reply

  • Hi Colby, Thanks again for these instructions. Worked great on my Intel macs and then finally, finally, on my PPC. The trick was that even though it didn't work before, complete removal of the previous install attempt as well as the uncompressed Imaging-1.1.6 folder is needed. Also, before installing PIL, I edited the JPEG_ROOT in setup.py to equal "/sw/lib" where the libjped had been put by fink.

    Posted by: tej on April 10, 2009 Reply

  • I had to set

    JPEG_ROOT = "/sw/lib/libjpeg.dylib"

    in the setup.py file.

    http://kylefox.ca/blog/2009/jan/11/how-install-pil-libjpeg-mac-os-x-105/

    Posted by: Thorarinn on Oct. 16, 2009 Reply

  • I was trying to manually install libjpeg, then manually install Imaging-1.1.6 ... apparently fink knows something about OS's library paths that configure doesn't

    Posted by: free flash templates on Jan. 21, 2010 Reply

  • It took a little long to install but it worked like a charm once it was installed. Just picked default for all the questions it asked. I am running Leopard on a 2006 MacBook with a number of virtualenvs running different Django sites. The above method install the PIL and libjpeg on the entire Mac so all the virtualenvs can use it

    Posted by: kaguillera on Oct. 18, 2011 Reply

  • I was trying to manually install libjpeg, then manually install Imaging-1.1.6 ... apparently fink knows something about OS's library paths that configure doesn't

    Posted by: Alan Usen on Oct. 21, 2011 Reply

  • Thank you so much for this.

    Posted by: olvus on Oct. 22, 2011 Reply

Comments on this post are closed.