Tkinter.PhotoImage doesn't not support png image Tkinter.PhotoImage doesn't not support png image tkinter tkinter

Tkinter.PhotoImage doesn't not support png image


PIL is now replaced by Pillow http://pillow.readthedocs.io/en/3.2.x/

solution:

from Tkinter import *import PIL.Imageimport PIL.ImageTkroot = Toplevel()im = PIL.Image.open("photo.png")photo = PIL.ImageTk.PhotoImage(im)label = Label(root, image=photo)label.image = photo  # keep a reference!label.pack()root.mainloop()

If PIL could not be found in code, you do need a pillow install:

pip install pillow


tkinter only supports 3 file formats off the bat which are GIF, PGM, and PPM. You will either need to convert the files to .GIF then load them (Far easier, but as jonrsharpe said, nothing will work without converting the file first) or you can port your program to Python 2.7 and use the Python Imaging Library (PIL) and its tkinter extensions to use a PNG image.

A link that you might find useful: http://effbot.org/tkinterbook/photoimage.htm


Tkinter 8.6 supports png file format while tkinter 8.5 does not. If you have the option upgrade python and you should be fine to use png.If you have to use an older version of python you should use Pillow (maintained pil fork) which also works on python3.

If you are starting a new project do not use python2 or PIL as suggested in the accepted answer, they are both depreciated technologies.