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'
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
Try to use Import Image, and PIL starts working ( it works in my case):
import Image
instead of
from PIL import Image
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]
Related
greetings ---
hey gues , I have an a problem with google.colab when I want to run this code :
# Import Image from wand.image module
from wand.image import Image
# Read image using Image() function
with Image(filename ="/content/Hand.jpeg") as img:
# Generate noise image using spread() function
img.noise("poisson", attenuate = 0.9)
img.save(filename ="noise_hand.jpeg")
the issue is with this command :
from wand.image import Image
it keep saying :
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-c8294d82387e> in <module>()
1 # Import Image from wand.image module
----> 2 from wand.image import Image
this issue only appears in colab, I mean, for example, it works fine with Microsoft visual studio.
pls guess someone help me to fix this problem, and thanks in advance
note: I already installed and imported the wand library
Try installing ImageMagick by running these in a cell before your code.
!sudo apt install imagemagick
!pip install wand
I have a Problem with the Pillow module.
So basically i tried the methods on this website installing it per pip install Pillow and also importing it per from PIL import Image and import PIL none of them worked
I would really appreciate it if someone helped
and thanks for reading. This is my code:
import pyautogui
import pyscreeze
from PIL import Image
lkchat = pyautogui.locateCenterOnScreen("python.png")
print ("lkchat")
I'm getting the following error message:
from PIL import Image
ImportError: No module named PIL
Kitty Star i would like to suggest you that replace PIL with pillow and then install pillow if your code does not run let me know the next error.
I cannot seem to figure out how to fix a problem with my code regarding import ImageTK from PIL. I have searched and downloaded Pillow different ways and the error of the code is still the same.
Traceback (most recent call last):
File "8_Age_Calculator_App.py", line 3, in <module>
from PIL import Image, ImageTK
ImportError: cannot import name 'ImageTK'
These are the import codes of the file
import PIL
from PIL import Image, ImageTK
import tkinter as tk
import datetime
and this is the code that is trying to import the image
main_image = Image.open('/Users/Brenden/Documents/Python_OOP/old-people-
running-illo_h.jpg')
main_image.thumbnail((100,100), Image.ANTIALIAS)
main_photo = ImageTK.Photoimage(main_image)
main_label_image = tk.Label(image=main_photo)
main_label.grid(column=1, row=0)
How may I fix this problem?
Use this command for Python 3
sudo apt-get install python3-pil.imagetk
You have a typo in the module you want to import. The k in ImageTk should be lower case:
from PIL import Image, ImageTk
this should solve your problem
and in your script you have another case typo, PhotoImage is CamelCase:
main_photo = ImageTk.PhotoImage(main_image)
Install it using this command.
sudo apt-get install python-imaging-tk
ImageTK is k(small letter) not K (capital letter)
from PIL import Image, ImageTk
To install for python2 type in terminal:
sudo apt-get install python-pil.imagetk
For python3 type:
sudo apt-get install python3-pil.imagetk
To import Image and ImageTk:
from PIL import Image, ImageTk
There's a typo in your script, it will be PhotoImage:
main_photo = ImageTk.PhotoImage(main_image)
Try to write this command in the terminal:
pip install pillow
It will install PIL packages
I have problem with import Image library in Python 2.7 on Windows. When I write:
import Image
I have error:
No module named Image
Library is added in project settings so I tried
from PIL import Image
Unfortunately now I have next error
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder zip not available
I have no idea what to do.
For windows:
python -m pip install Pillow
then in your python code:
from PIL import Image
Although this is a reasonably well documented problem, I can't find a solution.
I cannot import PIL and ImageTK.
Minimal example:
import Tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
image = Image.open('live.ppm')
photo = ImageTk.PhotoImage(image)
This produces the error:
File "C:\Anaconda\lib\site-packages\PIL\ImageTk.py", line 181, in paste
import _imagingtk
ImportError: No module named _imagingtk
I have tried:
conda install pillow
conda remove PIL
But no luck.
After uninstalling pillow and PIL:
pip install image
Fixed this issue.
Thanks for bringing this up. The ImageTk module is an extra extension that is not part of the default installation of Pillow.
This issue is long-standing: https://github.com/ContinuumIO/anaconda-issues/issues/150
We (Continuum) will investigate adding this module to our build process.
Try to verify the extension of the image, i got the same problem, and when i modified the extension the script worked