Reputation: 11
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'
Upvotes: 1
Views: 6161
Reputation: 1848
Try to use import Image
, and PIL starts working ( it works in my case):
import Image
instead of
from PIL import Image
Upvotes: -1
Reputation: 1
What I did is:
Open CMD typed "pip install pillow" if you have not yet install pillow
Copied "PIL" folder from [C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages]
Then paste it to [C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python39\Lib]
Upvotes: 0
Reputation:
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
Upvotes: 1