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
./configuresudo 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


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.
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?
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
Hi Thom.
Yes that is a type, I will amend it so future visitors have the correct info
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
[...] http://appelfreelance.com/2010/06/libjpeg-pil-snow-leopard-python2-6-_jpeg_resync_to_restart/ [...]
You forgot ./configure above sudo make clean
按照上述方法收到错误:
ImportError: libjpeg.so.7: cannot open shared object file
解决办法:echo ‘/usr/local/lib’ >> /etc/ld.so.conf
Hi there. I followed every step. All goes OK until the ‘python selftest.py’ where raise error:
*** JPEG support not installed
In fact all but ZLIB say “support not installed”.
But at install it says:
——————————————————————–
PIL 1.1.7 SETUP SUMMARY
——————————————————————–
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?
Regards,
Pedro
Hi,
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?
Thanks.
Alex
After all this I am stuck at an error output:
Symbol not found: _jpeg_resync_to_restart
you’re a superstar.
Thanks
Hi,
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.
That realy safed my day. Thank you very much.
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.
I would suggest using v6 or v7 haven’t tried v8 myself
what version of libjpeg did you download?
What version of Mac OS X are you using, and is it a 64-bit build?
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
I used
http://www.ijg.org/files/jpegsrc.v8.tar.gz
and had to use
JPEG_ROOT = libinclude(“/usr/local/lib”)
and it worked!!
Thank you so much, this post was very helpful,
Dorian
[...] applefreelance libjpeg and pil on snow leopard stackoverflow installing python pil and libjpeg on snow leopard [...]
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.
I’m glad I could help!
Also make sure to check out the upgrades section for OS X Lion, using Python 2.7
Thanks! Your post saved me a ton of time.
I can’t thank you enough for this. You have no idea how long i spent troubleshooting this before finding this page. THANK YOU!