Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python insert image into Tkinter error

Tags:

python

tkinter

I want to insert an image into my tkinter but I received error:

TclError: image "pyimage7" doesn't exist.

I am using WinPython-64-3.3.5.9. I tried "rozmery.gif" but didn't help.

    from tkinter import *        
    from PIL import ImageTk, Image

    app_root = Tk()

    #Setting it up
    img = ImageTk.PhotoImage(Image.open("rozmery.png"))

    #Displaying it
    imglabel = Label(app_root, image=img).grid(row=1, column=1) 

    app_root.mainloop()
like image 357
Tomáš Kmínek Avatar asked Nov 15 '25 18:11

Tomáš Kmínek


1 Answers

I had the same error message. I restarted the kernel (Spyder) and it worked perfectly fine. I have this kind of issue sometimes where the code works just fine but it refuses to work. Restarting the kernel is often the only way.

like image 177
Chris Ze Third Avatar answered Nov 18 '25 10:11

Chris Ze Third



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!