[Pythonmac-SIG] I can't grok PIL anymore...

Jerry LeVan jerry.levan at eku.edu
Sun Oct 16 02:11:45 CEST 2005


Here is an even simpler demo of my problem...
mandrill.jpg is in the directory where
python is invoked.

Jerry

[macjerry:~/python]$ pythonw
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import Image
 >>> im=Image.open("mandrill.jpg")
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/Users/jerry/Library/Python/2.4/site-packages/PIL/Image.py",  
line 1745, in open
     raise IOError("cannot identify image file")
IOError: cannot identify image file
 >>>

On Oct 15, 2005, at 7:23 PM, Jerry LeVan wrote:

> About a year+ ago I quit programming, currently my interest
> has been stimulated again and I am trying to get back up
> to speed.
>
> I started out futzing around with pyscopg 2.0.4. and tried
> to get it to build...
>
> I quickly realized that I was in bad shape ( memory wise...).
>
> I decided to upgrade to 2.4.1 and got the upgrade and the Tiger Python
> Fix and started again...
>
> I finally got the python interfaces for Postgresql and Sqlite build
> and convinced myself that things were getting better.
>
> I used the package manager to download PIL and things fell apart again
> I don't seem to be able to display any sort of image.
>
> Here is a little program that I sorta recollect that worked.
>
> from Tkinter import *
> import Image,ImageTk
> import sys
>
> def main():
>     filename = sys.argv[1]
>     root = Tk()
>     img = ImageTk.PhotoImage(file=filename)
>     label = Label(root, image=img)
>     label.pack()
>     root.mainloop()
>
> main()
>
> Running the above with any kind of graphics file
> gives a dump like:
>
> Traceback (most recent call last):
>   File "imageview.py", line 13, in ?
>     main()
>   File "imageview.py", line 8, in main
>     img = ImageTk.PhotoImage(file=filename)
>   File "/Users/jerry/Library/Python/2.4/site-packages/PIL/ 
> ImageTk.py", line 85, in __init__
>     image = Image.open(kw["file"])
>   File "/Users/jerry/Library/Python/2.4/site-packages/PIL/ 
> Image.py", line 1745, in open
>     raise IOError("cannot identify image file")
> IOError: cannot identify image file
> Exception exceptions.AttributeError: "PhotoImage instance has no  
> attribute '_PhotoImage__photo'" in <bound method PhotoImage.__del__  
> of <ImageTk.PhotoImage instance at 0x23edf0>> ignored
>
> If I drop the ImageTk prefix to the PhotoImage line I can view Gifs.
>
> Several other programs that I am fairly sure worked also fail with the
>  "cannot identify image file" error.
>
> Tkinter seems to be more or less working, I have a visual  
> Postgresql browser that is
> built out of a number of tk widgets.
>
> Tk itself seems to be working fine. I have written a photo browser  
> that can view a large
> number of image formats and it appears to be working fine.
>
> I installed PIL using the Package Manager and it installed into
> ~/Library/Python/2.4/site-packages.
>
> Can anyone offer any clues as to what my problem is?
>
> Jerry
>
>
>



More information about the Pythonmac-SIG mailing list