[Image-SIG] Installing libjpeg

Chris Barker Chris.Barker at noaa.gov
Tue May 18 01:36:25 CEST 2010


Mark Twenhafel wrote:
> Chris--I thought I had mailed this Friday, but it never appeared in image-sig, 
> so here goes again.  I'll continue with the interleaved response-style.  Thanks
> for the help--for my part, I'm working through K&R,

I doubt K&R will help there -- I'd look for something about gcc. Even 
though tis isn't linux, I learned a lot form "Linux Application 
Development". You can probably find a reference on linking on OS-X -- it 
does some things differently.

good luck.

-CHB


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


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Image-SIG mailing list