Skip to content
Sign upLog in

What is this error and how can you fix it?

Profile icon

Traceback (most recent call last):
File "", line 15, in
background = PhotoImage(file='The word hi.jpeg')
File "/usr/lib/python3.8/tkinter/", line 4061, in init
Image.init(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python3.8/tkinter/", line 4006, in init'image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "The word hi.jpeg"

You are viewing a single comment. View All
Answered by 19wintersp [earned 5 cycles]
View Answer
Profile icon

I believe this error suggests a corrupted or invalid image.

You might be able to fix this by using PIL.

Profile icon

Update: using PIL's ImageTk works correctly for me; replace line 16 with:

background = ImageTk.PhotoImage("The word hi.jpeg"))

and add this to the top:

from PIL import ImageTk, Image