tags:

views:

63

answers:

2

Hi,

I am at wit's end. I have a working install of python 2.6.5 with numpy and scipy. I want to use it to do some simple PCA which requires importing images. Well, I figured PIL was the way to go for this. So, following a guide, I downloaded and installed libjpeg6-b. I then used the following commands

tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
./configure --enable-shared --enable-static
make

I moved over to where I downloaded PIL 1.1.7 and did the following:

tar zxvf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
(edit the setup.py file to find libjpeg)
python setup.py build
python setup.py install

I then try to import _imaging and I get the famous ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL-1.1.7-py2.6-macosx-10.3-fat.egg/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL-1.1.7-py2.6-macosx-10.3-fat.egg/_imaging.so Expected in: dynamic lookup error.

I tried most/all of the solutions out there already and haven't found much success. I ran otool on my _imaging.so after I restricted my architecture to i386 and got:

Thomas$ otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so:

/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)

Furthermore, when I ran pip and got this output

    --------------------------------------------------------------------
PIL 1.1.6 BUILD SUMMARY
--------------------------------------------------------------------
version       1.1.6
platform      darwin 2.6.5 (r265:79359, Mar 24 2010, 01:32:55)
              [GCC 4.0.1 (Apple Inc. build 5493)]
--------------------------------------------------------------------
--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
--------------------------------------------------------------------
To check the build, run the selftest.py script.

for PIL 1.1.6.

I have tried switching to gcc 4.0 and compiling both libjpeg and PIL also.

Any help would be very much appreciated. Also, if you need any more information, please do not hesitate to ask.

+1  A: 

Do you know Macports (or Fink)? The easiest way to install software and packages is via Macports. Alternatively you could have a look at the Portfiles of Macports and see how they are compiling those libs.

ahojnnes
A: 

You can also use pip to install imaging

user easy_install to install pip

easy_install pip
pip install http://effbot.org/downloads/Imaging-1.1.6.tar.gz

Alternatively if this does not help you, I wrote an article on how to get PIL, libjpeg, _imaging to work with python 2.6 and snow leopard

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

ApPeL