Unable to import PIL into project - python

The PIL module should be installed because when I run the pip install pillow I get this message: Requirement already satisfied: pillow in [my installation route]. But, when I try to import this into a file, I get this error:
ModuleNotFoundError: No module named 'Pillow'
What am I doing wrong?

this has worked for me if your using vscode try install by typing py -m pip install pillow
from PIL import ImageTk,Image

Pillow is a fork of PIL, and the import is carried over.
import PIL
Should do the trick. The documentation has additional details:
https://pillow.readthedocs.io/en/stable/installation.html

Related

Why do I get an error trying to use pytesseract?

import pytesseract
import PIL
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
Im trying that code alone with many other ways to type the pile path as in double '\' etc but I still continue to get the error:
ModuleNotFoundError: No module named 'PIL'
In shell, run:
pip install Pillow
The error means you are missing some modules.
pip install --upgrade --force-reinstall Pillow
resolved my issue

Module pyfiglet not found

The code :
import pyfiglet
print(dir(pyfiglet))
The error :
ModuleNotFoundError: No module named 'pyfiglet'
Even though I downloaded "pip 21.0.1" and imported it, it does the same thing to "termcolor" package.
sorry i install pip and the command
pip install pifiglet
report this results
equirement already satisfied: pyfiglet in /usr/local/lib/python3.9/dist-packages (0.8.post1)
but if i do the original command i have this response
from pyfiglet import figlet_format
ImportError: cannot import name 'figlet_format' from 'pyfiglet' (/usr/local/lib/python3.9/dist-packages/pyfiglet/init.py)
but in this path there is the file...
Before you can import a library, it needs to already be on your drive. You are importing it into your file. In order to get it onto your drive in the first place, you have to install it.
From the command prompt, type:
pip install pifiglet
Once you've done that, you should be able to import it.

Heroku PIL ModuleNotFoundError: No module named 'Image'

I am creating a Heroku app in which I am using PIL and from PIL import Image.
When I run heroku local, it returns ModuleNotFoundError: No module named 'Image'. I have tried using Pillow instead of PIL, but it returns the same error. PIL and Pillow are both in my requirements.txt.
A link to my full github repo is: https://github.com/maivey/flower-image-classifier
Please help as I do not understand why it will not recognize PIL or Pillow
Maybe you need to install them.
If you use anaconda: conda install PIL
If you use pip: pip install PIL
Thanks

ImportError: No module named PIL python 2.7.10

I am not able to import PIL on macOS, it works fine on windows with python version 2.7.16.
Any help for python 2.7.10 would be much appreciated.
from PIL import Image
ERROR:-
ImportError: No module named PIL
I am getting this error with python (2.7.10) pip(19.1.1) on macos Mojave (10.14.4)
pip list outputs pillow in the packages version (5.2.0)
pip install pillow
Logs the following:
Requirement already satisfied: pillow in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (5.2.0)
But i am still unable to import the package.
Any workarounds for this?

Importing pytesseract

I have trying to use pytesseract for OCR (extracting text from the image). I have successfully installed pytessearct by using the command -
pip install pytessearct
When I try to install it again, it clearly says -
Requirement already satisfied (use --upgrade to upgrade):
pytesseract in ./site-packages
This means pytessearct is installed successfully. When i try to import this package in my iPython notebook using -
import pytessearct
It throws an error -
ImportError: No module named pytesseract
Why is that happening?
To use Python-tesseract - requires python 2.5+ or python 3.x - first you have to install PIL and pytesseract packages through pip:
pip install Pillow
pip install pytesseract
Then you have to download and install the tesseract OCR:
https://sourceforge.net/projects/tesseract-ocr-alt/?source=typ_redirect
As far as I know it automatically adds it to your PATH variable.
Then use it like this way:
import pytesseract
from PIL import Image
img = Image.open('Capture.PNG')
pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
print( pytesseract.image_to_string(img) )
I hope it helps :)

Categories

Resources