Skip to content

Instantly share code, notes, and snippets.

@machristie
Last active August 29, 2015 14:05
Show Gist options
  • Save machristie/01989953908e8937d02d to your computer and use it in GitHub Desktop.
Save machristie/01989953908e8937d02d to your computer and use it in GitHub Desktop.
Install Pillow on Mac OS X
#ZLIB_ROOT = None
brew_zlib_home = os.path.join(os.environ["BREW_HOME"], "opt", "zlib")
ZLIB_ROOT = os.path.join(brew_zlib_home, "lib"), os.path.join(brew_zlib_home, "include")
@machristie
Copy link
Author

To install Pillow, first need some dependencies installed using brew

brew install libtiff libjpeg webp little-cms2 zlib

I've already set the following environment variables, which I got from https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python

export CFLAGS=-I$(brew --prefix)/include
export LDFLAGS=-L$(brew --prefix)/lib

However, zlib is a "keg-only" formula. It isn't put into BREW_HOME/lib, etc. but instead
is put into BREW_HOME/opt/zlib. So we need to update the Pillow setup.py to be able
to find the lib and include directories.

Download the Pillow source zip file from pypi:
https://pypi.python.org/pypi/Pillow/2.5.1. Unzip it and edit setup.py. Change
line

ZLIB_ROOT = None

to

brew_zlib_home = os.path.join(os.environ["BREW_HOME"], "opt", "zlib")
ZLIB_ROOT = os.path.join(brew_zlib_home, "lib"), os.path.join(brew_zlib_home, "include")

Now you can run

python setup.py install

To verify that everything works, you can also run

python selftest.py --installed

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