Skip to content

Instantly share code, notes, and snippets.

@jywsn
Last active February 4, 2016 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jywsn/c9fc436a76f1186a35b4 to your computer and use it in GitHub Desktop.
Save jywsn/c9fc436a76f1186a35b4 to your computer and use it in GitHub Desktop.
Installing PIL on Mac OS
Sure, you should use Pillow. But sometimes you want PIL. Directions tested on Mac OS 10.11.3 with Xcode 7.2.1.
Install Xcode command line tools, if needed:
$ xcode-select --install
Download the PIL source distribution (Imaging 1.1.7) from http://effbot.org/downloads#imaging. Do an in-place build, and run the self test before installing:
$ tar -xvf Imaging-1.1.7.tar
$ cd Imaging-1.1.7
$ python setup.py build_ext -i
$ python selftest.py
Sample setup summary from build command:
--- TKINTER support available
*** JPEG support not available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
Oops, we want JPEG support. Download jpegsrc.v9b.tar.gz from http://www.ijg.org/files/. Configure, make, and install (assuming 9b):
$ ./configure --prefix=/usr/local/libjpeg-9b
$ make
$ sudo make install
Create a symbolic link that points /usr/local/libjpeg to /usr/local/libjpeg-9b:
$ sudo ln -s /usr/local/libjpeg-9b /usr/local/libjpeg
From in Imaging-1.1.7 directory, try the build again:
$ python setup.py clean
$ python setup.py build_ext -i
If it still can’t find JPEG support, edit setup.py and set:
JPEG_ROOT = libinclude("/usr/local/libjpeg")
Re-run build command and selftest. If everything is ok, install into your virtualenv:
$ <path to virtualenv>/bin/python setup.py install
Activate virtualenv and make sure it is there in pip freeze.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment