Skip to content

Instantly share code, notes, and snippets.

@morozgrafix
Last active December 20, 2015 13:19
Show Gist options
  • Save morozgrafix/6138037 to your computer and use it in GitHub Desktop.
Save morozgrafix/6138037 to your computer and use it in GitHub Desktop.
Steps to Install PIL on Mac OS X 10.8.4
Install JPEG library:
curl -O -L http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar -zxvf jpegsrc.v9.tar.gz
cd jpeg-9/
sudo CC="gcc -arch x86_64" ./configure -enable-shared -enable-static
sudo make
sudo make install
cd ..
Install PIL:
Update found more recent version of PIL at http://hg.effbot.org/pil-2009-raclette
curl -O -L http://hg.effbot.org/pil-2009-raclette/downloads/PIL-1.2a0-20110108.tar.gz
tar -zxvf PIL-1.2a0-20110108.tar.gz 
cd PIL-1.2a0/

clean up any existing builds by running

sudo rm -Rf build

edit setup.py and find JPEG_ROOT = None and replace it with

JPEG_ROOT = libinclude("/usr/local/lib")

save setup.py file

sudo python setup.py build

at this point you should be able to run python selftest.py and not get any errors related to JPEG

I see following results when I run it (ignoring ImageMath error at this point):

Traceback (most recent call last):
  File "selftest.py", line 11, in <module>
    from PIL import ImageMath
  File "./PIL/ImageMath.py", line 19, in <module>
    import _imagingmath
ImportError: No module named _imagingmath

And now it's time to install it

sudo python setup.py install

Run python selftest.py again after installation and you should see something along the lines:

--------------------------------------------------------------------
PIL 1.2a0 TEST SUMMARY 
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from /usr/local/Cellar/python/2.7.4/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- JPEG support ok (version 9.0)
--- ZLIB (PNG/ZIP) support ok (version 1.2.5)
--- FREETYPE2 support ok (version 2.4.11)
*** LITTLECMS support not installed
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.

You are done! To test type python to get into python interpreter then enter following commands:

import PIL
import Image
import _imaging

you shouldn't see any errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment