Check out the Latest Articles:
libjpeg, PIL, Snow Leopard, Python2.6, _jpeg_resync_to_restart

Man this has been an error that has been getting me down lately.

I have done tons of google searches for c _imaging not installed, PIL, libjpeg, Snow Leopard _jpeg_resync_to_restart and I have finally documented all my steps to rectify this issue.

If you don’t have this download it first.

http://www.ijg.org/files/jpegsrc.v7.tar.gz

go into your shell environment and untar by running the following

tar -zxvf jpegsrc.v7.tar.gz

cd jpeg-7

then run

sudo make clean
sudo CC="gcc -arch i386"./configure --enable-shared --enable-static
sudo make
sudo make install

Next get PIL and untar it

http://effbot.org/downloads/Imaging-1.1.6.tar.gz
tar -zxvf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6

If you already have PIL I would recommend running

sudo rm -Rf build

to clean any existing builds, this has caused me loads of errors and gray hairs!

in your setup.py file run find JPEG_ROOT

amend it so it looks as follows

JPEG_ROOT = libinclude(“/usr/local”)

Next move onto the build

sudo python setup.py build

if libjpeg is successfully installed you should be able to run python selftest.py without any errors relating to “jpeg”

sudo python setup.py install

if all has worked successfully you should be able to enter your python interpreter by executing python in your command line and also do the following:

import PIL
import Image
import _imaging

without any errors.

Just to triple check I have a simple jpeg on my desktop.

image = Image.open(“/Users/MyName/Desktop/myimage.jpeg”)
image.save(“/Users/MyName/Desktop/test.jpeg”)

should work without errors :)



  1. Joe J J on Monday 21, 2010

    Thank you! Seems like this problem is everywhere when one does a Google, but you are the only one with a solution that I could find.

    I was hoping that there was a way to do this without recompiling stuff. I happen to be using virtualenv. I did find that if I blew away my virtual env install and then reinstall with pip, the Imaging started to work again. These steps seemed to work (note, I’m using OSX)

    rm -rf ve
    echo “pil” > requirements.pip
    echo “django” >> requirements.pip
    sudo port -v install py26-pip
    virtualenv –no-site-packages –distribute ve
    . ./ve/bin/activate
    pip-2.6 install -E ./ve/ -r requirements.pip
    python
    >>import import ImageFont
    >>

    Hope this is useful.

  2. Thom801 on Monday 21, 2010

    Hey I am getting errors when I try to run the clean and configure commands:

    $:jpeg-7 thom$ sudo make clean
    Password:
    make: *** No rule to make target `clean’. Stop.
    $:jpeg-7 thom$ sudo make clean

    $:jpeg-7 thom$ sudo CC=”gcc -arch i386””./configure –enable-shared –enable-static
    sudo: illegal option — -
    usage: sudo [-n] -h | -K | -k | -L | -V | -v
    usage: sudo -l[l] [-AnS] [-g groupname|#gid] [-U username] [-u username|#uid] [-g groupname|#gid] [command]
    usage: sudo [-AbEHnPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u username|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] []
    usage: sudo -e [-AnS] [-C fd] [-g groupname|#gid] [-p prompt] [-u username|#uid] file …
    $:jpeg-7 thom$ sudo CC=”gcc -arch i386””./configure –enable-shared –enable-static

    Any ideas?

  3. Thom801 on Monday 21, 2010

    Also in your article there is a typo I believe. When you say:

    in your settings.py file run find JPEG_ROOT

    I believe you mean:

    in your setup.py file run find JPEG_ROOT

  4. Arno Smit on Monday 21, 2010

    Hi Thom.

    Yes that is a type, I will amend it so future visitors have the correct info

  5. Arno Smit on Monday 21, 2010

    The reason you didn’t get the correct results was because it read

    sudo CC=”gcc -arch i386″” (NOTE THAT THERE ARE TWO, SHOULD ONLY BE ONE

    So, it should be as follows

    sudo CC=”gcc -arch i386” ./configure –enable-shared –enable-static

  6. AdamN on Monday 21, 2010

    You forgot ./configure above sudo make clean

  7. higkoo on Monday 21, 2010

    按照上述方法收到错误:
    ImportError: libjpeg.so.7: cannot open shared object file

  8. higkoo on Monday 21, 2010

    解决办法:echo ‘/usr/local/lib’ >> /etc/ld.so.conf