Skip to content

Instantly share code, notes, and snippets.

@ryanniemeyer
Created June 21, 2012 18:49
Show Gist options
  • Save ryanniemeyer/2967728 to your computer and use it in GitHub Desktop.
Save ryanniemeyer/2967728 to your computer and use it in GitHub Desktop.
Installing PIL in virtualenvs

Update:

@thatmattbone gave a tweet that led me to Pillow, a fork of PIL that's much simpler to install. Only change I had to make was imports. I had been importing just "Image" and needed to change to "PIL.Image". Installing Pil(low) in a virtual env is now a piece of cake:

pip install Pillow

Before Pillow, this is what I was doing...

Mac OS X

Lion

If you simply try to "pip install PIL" in your virtualenv it will work for png and gif, but will asplode on jpeg's :(

Thanks to http://devdetails.com/2011/09/20/install-pil-in-a-virtualenv-on-mac-osx-lion/ , here's command line copy/paste to install:

brew install jpeg
workon myenv
pip install --upgrade --no-install PIL
sed -i -e 's:JPEG_ROOT = None:JPEG_ROOT = "/usr/local/Cellar/jpeg/8c/":' $VIRTUAL_ENV/build/PIL/setup.py
sed -i -e 's:FREETYPE_ROOT = None:FREETYPE_ROOT = libinclude("/usr/X11"):' $VIRTUAL_ENV/build/PIL/setup.py
pip install --upgrade PIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment