Installing PIL on the Mac

The Python Imag­ing Library, PIL, is a very use­ful addi­tion to your Python instal­la­tion if you need to manip­u­late pic­tures. Django uses it to val­i­date upload images for example.

On a Mac you do need to install lib­jpeg beforehand.

Install lib­jpeg:

  • Get the source:

  • Extract the archive.

  • Move inside the source direc­tory and exe­cute the fol­low­ing commands:

    cp /usr/share/libtool/config.sub .
    cp /usr/share/libtool/config.guess .
    ./configure --enable-shared
    sudo mkdir -p /usr/local/include
    sudo mkdir -p /usr/local/bin
    sudo mkdir -p /usr/local/lib
    sudo mkdir -p /usr/local/man/man1
    sudo make install

Install PIL:

  • Get PIL at:

  • Extract the archive.

  • Move inside the source directory

  • Change the fol­low­ing val­ues in from the default None to:

    JPEG_ROOT = "/usr/local/include"
    ZLIB_ROOT = "/usr/local/include"
  • Check if every­thing is well configured:

    python build_ext -i
  • If no errors are found and the required libraries are installed (like JPEG sup­port), install PIL:

    sudo python install

And that’s it, I’ve tried this on Mac OS Leop­ard, and it works fine, let me know how it went for you.

14 March, 2008 — 3 comments


christian posta 26 July, 2011 05:57

Thanks for post­ing this! I was get­ting errors try­ing to upload images with django on mac os x lion, but fol­low­ing this guide fixed the issue for me! i never had to do this on ubuntu, from what i could recall… any idea why this is so much more involved on mac?

thanks again!

wouter 24 September, 2011 15:44

Another small note:

The con­fig files are located in a sep­a­rate con­fig direc­tory in Lion:

/usr/share/libtool/config/config.sub /usr/share/libtool/config/config.guess

Amir Latifi 14 February, 2012 04:37

Thanks. Resolved my problem. :)

Leave a comment