Install Python Image Library (PIL) on OSX

PIL or Python Imaging Library is a library that allows you to manipulate images in Python programming language, trying to install “PIL” using “pip” tool won’t work perfectly so here is how to proper installation.

Install Brew

Brew is a package management system that simplifies the installation of software on Mac OS X, you can install it easily with the following command:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Install Pil

Actually we will install ”pillow” a fork of ”pil”:

brew install samueljohn/python/pillow

Configure your Python Path

To make PIL available to Python we add its path to PYTHONPATH variable:

vi ~/.bash_profile
PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
export PYTHONPATH

Check it

To test if you have PIL installed:

python -c "import PIL.Image"

You shouldn’t get any errors.

One thought on “Install Python Image Library (PIL) on OSX”

  1. Hello,

    I’m new to python. Installing it on a Mac El Capitan (new to Mac too.)

    Here’s my python version info:
    Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:39:00)
    [GCC 4.2.1 (Apple Inc. build 5577)] on darwin

    I get the following error:
    __________________________________________
    python -c “import PIL.Image”
    Traceback (most recent call last):
    File “”, line 1, in
    File “/usr/local/lib/python2.7/site-packages/PIL/Image.py”, line 63, in
    from PIL import _imaging as core
    ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PIL/_imaging.so, 2): no suitable image found. Did find:
    /usr/local/lib/python2.7/site-packages/PIL/_imaging.so: mach-o, but wrong architecture
    __________________________________________

    I edited the bash_profile and I see that it added a new section for what seems to be a newer version of python. I’ve since deleted that text from the bash_profile file but the above error persists.

    I got this point because I was trying to fix the following error when running my code:
    __________________________________________
    raise ImportError(“The _imaging C module is not installed”)
    ImportError: The _imaging C module is not installed
    __________________________________________

    Thanks in advance for your help!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.