3

I download my Python 2.7 with Anaconda. I'm using windows 7. I tried following:

from Tkinter import Tk, Frame, Canvas
import ImageTk

t = Tk()
t.title("Transparency")

frame = Frame(t)
frame.pack()

canvas = Canvas(frame, bg="black", width=500, height=500)
canvas.pack()

photoimage = ImageTk.PhotoImage(file=r"test.png")
canvas.create_image(150, 150, image=photoimage)

t.mainloop()

I get following Error:

ImportError: No module named _imagingtk

I think I need to install ImageTk, how this ImportError: No module named _imagingtk says.

But how can I install it on Windows? Where should I type this code?

 $ pip install ImageTk

If I try:

 import ImageTk

I don't get any Error. What means ImageTk is actually already installed, right?

Thanks

Community
  • 1
  • 1
Hangon
  • 2,449
  • 7
  • 23
  • 31

1 Answers1

1

ImageTk is defined in the package PIL which you should install with:

pip install Pillow

Pillow is a port of PIL that is accessible through pip. Now import PIL like so:

from PIL import ImageTk
Malik Brahimi
  • 16,341
  • 7
  • 39
  • 70