HI

I'm not an expierenced python programmer (yet)
I want to display an image on a screen. I already installed PIL 1.1.6,
and i am using the Tkinter GUI.
I don't know what is missing (or were I went wrong installing the PIL), but this message <see below> is popping up every time.

Traceback (most recent call last):
File "C:\Python26\helpimage.py", line 10, in <module>
tkim = ImageTk.PhotoImage(im) # Convert the image object to a Tkinter PhotoImage object
File "C:\Python26\lib\site-packages\PIL\ImageTk.py", line 116, in __init__
self.paste(image)
File "C:\Python26\lib\site-packages\PIL\ImageTk.py", line 166, in paste
im.load()
File "C:\Python26\lib\site-packages\PIL\ImageFile.py", line 155, in load
self.load_prepare()
File "C:\Python26\lib\site-packages\PIL\ImageFile.py", line 223, in load_prepare
self.im = Image.core.new(self.mode, self.size)
File "C:\Python26\Lib\site-packages\PIL\Image.py", line 36, in __getattr__
raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed

I have found an _imaging.pyd module in the C:\Python26\Lib\site-packages\PIL library.
How can I fix this problem?

< I used this code :

import Tkinter as Tk                     
import Image
import ImageTk

r = Tk.Tk()
c = Tk.Canvas(r, width=500, height=500)
c.pack(fill='both', expand='yes')
im = Image.open('linux.jpg')            # Open a jpeg file into an image object
tkim = ImageTk.PhotoImage(im)                 # Convert the image object to a Tkinter PhotoImage object
c.create_image(100, 100, image=tkim)          # Draw the Tkinter image object on the canvas

>

I assume that you downloaded and installed
PIL-1.1.6.win32-py2.6.exe
for Python26

I don't use Python26, but this program works just fine with Python25 and PIL116 ...

import Tkinter as Tk
import Image
import ImageTk

root = Tk.Tk()
c = Tk.Canvas(root, width=500, height=500)
c.pack(fill='both', expand='yes')
# Open a jpeg file into an image object
im = Image.open('linux.jpg')
# Convert the image object to a Tkinter PhotoImage object
tkim = ImageTk.PhotoImage(im)
# Draw the Tkinter image object on the canvas
c.create_image(100, 100, image=tkim)

root.mainloop()

Also, since you are not giving a full path, make sure your image file is in the working directory.

The image file was in the working directory.
I re-installed python 2.6, and PIL 1.1.6
It didn't help. Maybe the fact that I was not able to instal the PIL automaticly (I had to store the PIL-package in my Python26 directory before the install program would do its job) has something to do with it.
At last I copied the _image.pyd and the _imagetk.pyd into my Python26 directory (read it somewhere on the internet). And my problems is 'solved'.
Still don't know what caused the problem, but this work-around seems to work for now.

Just a question, what is your operating system?

Vista sometimes gets on a silly security trip and simply does not install certain .dll and .pyd files. The nasty thing about it, it doesn't tell you!

My operating system is Windows Xp.

I am still not happy with my work-around. The fact that I am learning Python doesn't help either. I am just not able to figure out if the problems I get are caused by me (as a starter) or by the current software status on my computer. When I did some checks (found -again- on the internet) I saw for instance that my Image could be imported (used IDLE with -v) but the dynamic part was not loaded. In the given example there was a dynamic part. However it was just a sort of list with some lines to give you an idea of how it should/could look like. (I am not even sure if I need that dynamic part.)

Is there a list , or maybe a procedure, so that I can verify my installation?
Is there a path-parameter hidden somewere I should set?
The visible path parameters looked fine (used print path in IDLE)

I think you are so right, my PIL installation is not complete, and I have no idea what is still missing.
Should I go to Python 2.5.4 and the corresponding PIL?
Is that a more stable version?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.