Installing PIL on Snow Leopard - NOTHING WORK

I am trying to install PIL on Snow Leopard using Python 2.6.1, GCC 4.2.1, PIL 1.1.7, and tried with libjpeg6b and libjpeg7 - nothing works. I cleared all traces of libjpeg / pil / zlib from fink, tried various compiler options, etc. And used http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/ and http://www.brambraakman.com/blog/comments/installing_pil_in_snow_leopard_jpeg_resync_to_restart_error/(not a link because StOv only allows me to post ...)

4 bits of potentially useful information:

OTOOL does not show libjpeg as a dependency

otool -L /Library/Python/2.6/site-packages/PIL/_imaging.so /Library/Python/2.6/site-packages/PIL/_imaging.so: /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0) 

I get these strange compiler messages

 i686-apple-darwin10-gcc-4.2.1: -framework: linker input file unused because linking not done i686-apple-darwin10-gcc-4.2.1: Tcl: linker input file unused because linking not done i686-apple-darwin10-gcc-4.2.1: -framework: linker input file unused because linking not done i686-apple-darwin10-gcc-4.2.1: Tk: linker input file unused because linking not done gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/sw/include/freetype2 -I/sw/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c Tk/tkImaging.c -o build/temp.macosx-10.6-universal-2.6/Tk/tkImaging.o -framework Tcl -framework Tk In file included from /System/Library/Frameworks/Tk.framework/Headers/tk.h:78, from Tk/tkImaging.c:51: 

selftest.py fails due to _imagingmath (after I used the second link above before it failed too much due to _imaging)

 Themistocles:Imaging-1.1.7 me$ python selftest.py Traceback (most recent call last): File "selftest.py", line 11, in <module> from PIL import ImageMath File "./PIL/ImageMath.py", line 19, in <module> import _imagingmath ImportError: No module named _imagingmath 

Everything except selftest.py fails due to _imaging

 >>> import _imaging Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dlopen(/Library/Python/2.6/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart Referenced from: /Library/Python/2.6/site-packages/PIL/_imaging.so Expected in: flat namespace in /Library/Python/2.6/site-packages/PIL/_imaging.so 

Please, help! This is getting ridiculous. I would even be happy to be able to compile PIL sans jpeg support at this point!

+3
source share
3 answers

I recently wrote an article on how to get PIL, django, libjpeg to work well with Snow Leopard

http://appelfreelance.com/2010/06/libjpeg-pil-snow-leopard-python2-6-_jpeg_resync_to_restart/

I will also copy it here for you.

If you do not have this download, first.

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

go to the shell environment and release by doing 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

Then get a PIL and release 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 a PIL, I would recommend running

sudo rm -Rf build

to clean all existing assemblies, it caused a lot of bugs and gray hair!

in settings.py file find find JPEG_ROOT

change it so it looks like this

JPEG_ROOT = libinclude ("/ usr / local")

Then go to build

sudo python setup.py build

If libjpeg is successfully installed, you will be able to run python selftest.py without any "jpeg" related errors

sudo python setup.py install

if everything worked successfully, you should be able to enter your python interpreter by running python on the command line, and also follow these steps:

import PIL
import Image
import _imaging

no mistakes.

Just to check the triple 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

+5
source

Download macport:

 http://www.macports.org/install.php 

Then use it for pil:

 http://trac.macports.org/browser/trunk/dports/python/py-pil/Portfile 

I also had a lot of problems with this, but the port was managed.

+1
source

When trying to install PIL, I always got some gcc error screens. At some point, something works for me (perhaps through MacPorts), so now my solution is to copy it to the appropriate site packages (for example, inside the new virtualenv).

I just posted it here: http://blogmaker.com/PIL-1.1.6-for-MacOSX-10.5-Leopard.zip

Works for me; I don't know if this will work for anyone else! Feel free to contact me with suggestions. And let me know if there is a better place where I should post it. PIL both very cool and royal chores; it would be nice to have a final place to support. There are other problems related to PIL that I have never solved.

0
source

All Articles