<pre>Chris--I thought I had mailed this Friday, but it never appeared in image-sig, <br>so here goes again. I'll continue with the interleaved response-style. Thanks<br>for the help--for my part, I'm working through K&R, hoping that this will teach<br>
me enough about compiling and linking C to puzzle out why this package isn't<br>installing seamlessly.<br><br>Mark<br><br>>Mark Twenhafel wrote:<br>>><i> Try adding<br></i>>><i> <br></i>>><i> print Image.core.__file__<br>
</i>>><i> <br></i>>><i> to your script and make sure that the output is what you expect.<br></i>><br>>what was the result of that?<br><br>redpoint:~/sandbox/python/persfin1 mark$ python<br>Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) <br>
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin<br>Type "help", "copyright", "credits" or "license" for more information.<br>>>> import Image<br>>>> print Image.core.__file__<br>
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so<br>>>> <br><br><br>><br>>><i> At this point, my working hypothesis is that I did not install libjpeg <br></i>>><i> correctly. I'm working on OS X Tiger. What I did was download <br>
</i>>><i> "jpegsrc.v8a.tar.gz"; double-click in my download window in Firefox to <br></i>>><i> untar; move the untarred "jpeg-8" folder to /Application; open Terminal <br></i>>><i> and cd'ed to /Applications/jpeg-8; finally, I ran "./configure", "make", <br>
</i>>><i> and "make install". <br></i>>><i> <br></i>>><i> It could be--and I don't know--that this install procedure did not <br></i>>><i> correctly add libjpeg to my Python 2.6 installation<br>
</i>><br>>no it wouldn't have done that.<br>><br>><i>> or that I need to <br></i>>><i> rebuild site-packages/PIL/_imaging.so in order to link-in libjpeg.<br></i>><br>>indeed you do.<br>><br>
>><i> Belated point of clarification: I subsequently installed PIL using the <br></i>>><i> these instructions:<br></i>>><i> $ cd Imaging-1.1.7<br></i>>><i> $ python setup.py build_ext -i<br>
</i>>><i> $ python selftest.py<br></i>><br>>that should have built a new PIL, but it won't have installed it.<br>><br>>Did the selftest run OK?<br><br>redpoint:/Applications/Imaging-1.1.7 mark$ python selftest.py<br>
--------------------------------------------------------------------<br>PIL 1.1.7 TEST SUMMARY <br>--------------------------------------------------------------------<br>Python modules loaded from ./PIL<br>Binary modules loaded from ./PIL<br>
--------------------------------------------------------------------<br>--- PIL CORE support ok<br>--- TKINTER support ok<br>--- JPEG support ok<br>--- ZLIB (PNG/ZIP) support ok<br>--- FREETYPE2 support ok<br>*** LITTLECMS support not installed<br>
--------------------------------------------------------------------<br>Running selftest:<br>--- 57 tests passed.<br>redpoint:/Applications/Imaging-1.1.7 mark$ <br><br><br>><br>>><i> I just noticed that the file "site-packages/PIL/_imaging.so" was created <br>
</i>>><i> last October.<br></i>><br>>which is why you are getting an old one here.<br><br>The last few lines of a long listing of PIL follow:<br><br>-rw-r--r-- 1 root admin 3047 Oct 11 2009 XpmImagePlugin.pyc<br>
-rw-r--r-- 1 root admin 231 Dec 3 2006 __init__.py<br>-rw-r--r-- 1 root admin 180 Oct 11 2009 __init__.pyc<br>-rw-r--r-- 1 root admin 1406408 Oct 11 2009 _imaging.so<br>-rw-r--r-- 1 root admin 87420 Oct 11 2009 _imagingft.so<br>
-rw-r--r-- 1 root admin 89240 Oct 11 2009 _imagingmath.so<br>-rw-r--r-- 1 root admin 54056 Oct 11 2009 _imagingtk.so<br>redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ <br>
<br><br><br>><br>>><i> If so, would be be possible or likely that this was built <br></i>>><i> using the version of libjpeg that didn't install on my machine?<br></i>><br>>yup.<br>><br>>><i> If this <br>
</i>>><i> is correct, what is the best way to proceed? My first inclination is to <br></i>>><i> delete the directory site-packages/PIL and reinstall. <br></i>><br>>yup -- you may not even need to delete, but it won't hurt.<br>
><br>>Take a look for a new _imaging.so that you should have just built. If <br>>you really want to know what it's linked to, try:<br>><br>>$ otool -L _imaging.so<br><br><br>Interpreting this is beyond me, at this point:<br>
<br>redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ otool -L _imaging.so<br>_imaging.so:<br> /usr/local/lib/libjpeg.7.dylib (compatibility version 8.0.0, current version 8.0.0)<br>
/opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)<br> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.9)<br>redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ <br>
<br><br><br>><br>>But you might just do:<br>><br>>setup.py install<br>><br>>and see if it now works.<br><br>The following code still produces the following exception:<br><br>redpoint:~/sandbox/python/persfin1 mark$ cat ./mwm.py<br>
#!/usr/local/bin/python<br>from Tkinter import *<br>import Image<br>import ImageTk<br><br>class Application(Frame):<br> def __init__(self, master=None):<br> Frame.__init__(self, master)<br> self.grid()<br>
self.createWidgets()<br><br> def createWidgets(self):<br> self.cnv = Canvas(self)<br> self.img = ImageTk.PhotoImage(Image.open("/Applications/Imaging-1.1.7/Images/lena.jpg"))<br> cvnitem = self.cnv.create_image(100, 100, image=self.img)<br>
self.cnv.grid()<br><br>app = Application()<br>app.master.title("Sample application")<br>app.mainloop()<br><br>redpoint:~/sandbox/python/persfin1 mark$ ./mwm.py<br>Traceback (most recent call last):<br> File "./mwm.py", line 18, in <module><br>
app = Application()<br> File "./mwm.py", line 10, in __init__<br> self.createWidgets()<br> File "./mwm.py", line 14, in createWidgets<br> self.img = ImageTk.PhotoImage(Image.open("/Applications/Imaging-1.1.7/Images/lena.jpg"))<br>
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageTk.py", line 116, in __init__<br> self.paste(image)<br> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageTk.py", line 166, in paste<br>
im.load()<br> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageFile.py", line 180, in load<br> d = Image._getdecoder(self.mode, d, a, self.decoderconfig)<br> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/Image.py", line 375, in _getdecoder<br>
raise IOError("decoder %s not available" % decoder_name)<br>IOError: decoder jpeg not available<br>redpoint:~/sandbox/python/persfin1 mark$ <br><br><br>><br>>We really do need to get a Mac binary built!<br>
><br>>-CHB<br>><br>><br>><br>><br>><br>>-- <br>>Christopher Barker, Ph.D.<br>>Oceanographer<br>><br>>Emergency Response Division<br>>NOAA/NOS/OR&R (206) 526-6959 voice<br>
>7600 Sand Point Way NE (206) 526-6329 fax<br>>Seattle, WA 98115 (206) 526-6317 main reception<br>><br><a href="http://mail.python.org/mailman/listinfo/image-sig">>Chris.Barker at noaa.gov</a><br>
><br><br>Thanks to anyone looking at this. Like I said, I want to get this running, but I'm not asking<br>anyone to do my own debugging. I'll keep hacking away at this at my level.<br><br>Mark<br><br><br></pre>