1

I am on Windows 10 and my python 3 code is as follows:

from tkinter import *
from PIL import ImageTk, Image

root = Tk()
root.title("Images")
root.iconbitmap("C:/Users/[name]/mu_code/GUI Practice/icon.ico")

# my_img = ImageTk.PhotoImage(Image.open("threat.jpg")


button_quit = Button(root, text="Exit Program", command=root.destroy)
button_quit.pack()

root.mainloop()

When I try to run this it gives the following error:

Traceback (most recent call last): File "c:\users[name]\mu_code\gui practice\images.py", line 2, in from PIL import ImageTk, Image ModuleNotFoundError: No module named 'PIL'

I have used pip install to download Pillow and attempted to download it to different locations to fix the problem but could not as the command prompt stated that the module was already downloaded. How can I fix this issue?

Edit:

import Image

or

import ImageTk

doesn't work either.

I have already run pip install Pillow and have one interpreter, being 'Mu'

3 Answers3

1

What you see here as PIL is actually pillow library

from PIL import ImageTk, Image

Run the command:

pip install Pillow

Check out for PIL

0

What I did is:

  1. Open CMD typed "pip install pillow" if you have not yet install pillow

  2. Copied "PIL" folder from [C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages]

  3. Then paste it to [C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python39\Lib]

ouflak
  • 2,458
  • 10
  • 44
  • 49
-1

Try to use Import Image, and PIL starts working ( it works in my case):

import Image

instead of

from PIL import Image 
BlackMath
  • 1,708
  • 1
  • 11
  • 14