Issue with Images in GUI python
Question: I am using python 2.7 and for some reason it doesn't recognize some of the
modules. I want to print an image with Tkinter and its just doesn't work.

    
    
    from Tkinter import *
    import ImageTk
    
    root = Tk()
    
    frame = Frame(root)
    frame.pack()
    
    canvas = Canvas(frame, bg="black", width=500, height=500)
    canvas.pack()
    
    photoimage = ImageTk.PhotoImage(file="Logo.png")
    canvas.create_image(150, 150, image=photoimage)
    
    root.mainloop()

The error is:

    
    
    C:\Python27\python.exe D:/Users/user-pc/Desktop/Appland/Project.py
    Traceback (most recent call last):
      File "D:/Users/user-pc/Desktop/Appland/Project.py", line 2, in <module>
        import ImageTk
    ImportError: No module named ImageTk
    
    Process finished with exit code 1


Answer: `ImageTk` is a part of the `PIL` module.

You need to use `from PIL import ImageTk`

You'll also want to save a reference to your image. Here's one example.

    
    
     photoimage = ImageTk.PhotoImage(file="Logo.png")
     root.image = photoimage
     canvas_image = canvas.create_image(150, 150, image=root.image)
    

