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.

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
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 file run find JPEG_ROOT

amend it so it looks as follows

JPEG_ROOT = libinclude(“/usr/local”)

Next move onto the build

sudo python build

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

sudo python 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 =“/Users/MyName/Desktop/myimage.jpeg”)“/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
    >>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
    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 file run find JPEG_ROOT

    I believe you mean:

    in your 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: cannot open shared object file

  8. higkoo on Monday 21, 2010

    解决办法:echo ‘/usr/local/lib’ >> /etc/

  9. pedromagnus on Monday 21, 2010

    Hi there. I followed every step. All goes OK until the ‘python’ where raise error:
    *** JPEG support not installed
    In fact all but ZLIB say “support not installed”.
    But at install it says:
    version 1.1.7
    platform darwin 2.6.5 (r265:79063, May 26 2010, 02:56:58)
    [GCC 4.2.1 (Apple Inc. build 5659)]
    — TKINTER support available
    — JPEG support available
    — ZLIB (PNG/ZIP) support available
    — FREETYPE2 support available
    — LITTLECMS support available

    I’m on OSX 10.6.4 with Python2.6
    Any ideas?

  10. Alex Michael on Monday 21, 2010


    I followed these instructions but I got this error:

    ld: warning: in /usr/local/lib/libjpeg.dylib, file was built for i386 which is not the architecture being linked (x86_64)

    Hence, linking is not done and the _imaging C library is not installed.

    Any ideas?


  11. Gnarlodious on Monday 21, 2010

    After all this I am stuck at an error output:

    Symbol not found: _jpeg_resync_to_restart

  12. jon on Monday 21, 2010

    you’re a superstar.

  13. Ara on Monday 21, 2010


    I have a quick question about the code you have up here: when I untar jpegsrc v8, it untars fine; however when I get to the step sudo make clean, I get an error as follows:

    make: *** No rule to make clean. Stop.

    any suggestions for this? Thanks.

  14. Andreas on Monday 21, 2010

    That realy safed my day. Thank you very much.

  15. Jamshid on Monday 21, 2010

    FWIW I was seeing this trying to use Google App Engine on Snow Leopard. I do have macports installed, but GAE was using /usr/bin/python. Once I changed the Python Path in preferences to /opt/local/bin/python2.6, it got around this error. GAE is buggy with this setting, I had to change it a couple of times — check your log output to be sure the right one is being called.

  16. Arno Smit on Monday 21, 2010

    I would suggest using v6 or v7 haven’t tried v8 myself

  17. Arno Smit on Monday 21, 2010

    what version of libjpeg did you download?

  18. Arno Smit on Monday 21, 2010

    What version of Mac OS X are you using, and is it a 64-bit build?

  19. Arno Smit on Monday 21, 2010

    according to your output it seems like it should work fine, have you tried importing _imaging PIL and Image into your current django?

    import PIL
    from PIL import Image
    import _imaging

  20. Dorian on Monday 21, 2010

    I used

    and had to use

    JPEG_ROOT = libinclude(“/usr/local/lib”)

    and it worked!!

    Thank you so much, this post was very helpful,

  21. [...] applefreelance libjpeg and pil on snow leopard stackoverflow installing python pil and libjpeg on snow leopard [...]

  22. Arif Harbott on Monday 21, 2010

    Thanks so much for your post, it saved me so much time and effort. I am using OSX Lion and it worked perfectly for me.

  23. Arno Smit on Monday 21, 2010

    I’m glad I could help!

    Also make sure to check out the upgrades section for OS X Lion, using Python 2.7

  24. Zach on Monday 21, 2010

    Thanks! Your post saved me a ton of time.

  25. Josh on Monday 21, 2010

    I can’t thank you enough for this. You have no idea how long i spent troubleshooting this before finding this page. THANK YOU!