I need to open images (png, jpg) in a Python + Tkinter program. The PIL seems to be installed correctly (used Pillow).
from PIL import Image, ImageTk from Tkinter import Tk root = Tk() image = Image.open('/home/1.png') photo = ImageTk.PhotoImage(image) label = Label(root, image=photo) label.pack() root.mainloop()
However, an error occurs:
Traceback (most recent call last): File "1.py", line 10, in <module> photo = ImageTk.PhotoImage(image) File "build/bdist.linux-x86_64/egg/PIL/ImageTk.py", line 123, in __init__ except: File "build/bdist.linux-x86_64/egg/PIL/ImageTk.py", line 188, in paste raise # configuration problem; cannot attach to Tkinter ImportError: cannot import name _imagingtk
What could be the problem? The _imagingtk itself is imported normally (I mean "import _imagingtk"), but this does not solve the problem.
PS If there is a simpler way to open an image in the Tkinter window - rekvestiruyu it.