Я новичок в Tkinter, и это базовый c код отображения изображения, который я нашел в inte rnet.
import tkinter as tk
from PIL import ImageTk, Image
path = r'.\0030001621.jpg'
root = tk.Tk()
img = ImageTk.PhotoImage(Image.open(path))
panel = tk.Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
root.mainloop()
Выдает эту ошибку:
---------------------------------------------------------------------------
TclError Traceback (most recent call last)
<ipython-input-10-ed688d6a5ab6> in <module>
7 root = tk.Tk()
8 img = ImageTk.PhotoImage(Image.open(path))
----> 9 panel = tk.Label(root, image = img)
10 panel.pack(side = "bottom", fill = "both", expand = "yes")
11 root.mainloop()
c:\users\fatima.arshad\appdata\local\continuum\anaconda2\envs\web_scraping\lib\tkinter\__init__.py in __init__(self, master, cnf, **kw)
2764
2765 """
-> 2766 Widget.__init__(self, master, 'label', cnf, kw)
2767
2768 class Listbox(Widget, XView, YView):
c:\users\fatima.arshad\appdata\local\continuum\anaconda2\envs\web_scraping\lib\tkinter\__init__.py in __init__(self, master, widgetName, cnf, kw, extra)
2297 del cnf[k]
2298 self.tk.call(
-> 2299 (widgetName, self._w) + extra + self._options(cnf))
2300 for k, v in classes:
2301 k.configure(self, v)
TclError: image "pyimage4" doesn't exist
Как мне решить эту проблему?