Mehmet Akharman
Mehmet Akharman

Reputation: 11

ModuleNotFoundError: No module named 'PIL', ImageTk

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

Answers (3)

BlackMath
BlackMath

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

aginagincoder
aginagincoder

Reputation: 1

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]

Upvotes: 0

user15801675
user15801675

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

Related Questions