AttributeError: Image has no attribute 'open' AttributeError: Image has no attribute 'open' tkinter tkinter

AttributeError: Image has no attribute 'open'


from tkinter import * 

this imports everything from tkinter, including Image:

Init signature: Image(imgtype, name=None, cnf={}, master=None, **kw)Docstring:      Base class for images.File:           [...]Type:           typeSubclasses:     PhotoImage, BitmapImage

So, the Image module that you import earlier from PIL is overwritten.

you can

a) reverse the order:

from tkinter import *from PIL import Image, ImageTk

b) import only that what you need from tkinter

from PIL import ImageTk, Imagefrom tkinter import Tk

c) import Image as something else:

from PIL import ImageTkfrom PIL import Image as PILImagefrom tkinter import * 


You can do onething try to use this snippet

import PIL.Imageimport PIL.ImageTkim = PIL.Image.open("download.png")photo = PIL.ImageTk.PhotoImage(im)