Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

python - ModuleNotFoundError: No module named 'PIL' ,During handling of the above exception, another exception occurred:

I was using pytesseract for OCR from images. Everything was working fine .. till I tried pip install pillow and pip easy install pillow in my cmd just for trying a random crop . After that when I try to import pytesseract. It keeps throwing error

Traceback (most recent call last):
  File "C:Python39libsite-packagespytesseractpytesseract.py", line 28, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pytesseract
  File "C:Python39libsite-packagespytesseract\__init__.py", line 2, in <module>
    from .pytesseract import ALTONotSupported
  File "C:Python39libsite-packagespytesseractpytesseract.py", line 30, in <module>
    import Image
ModuleNotFoundError: No module named 'Image'

Screenshot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are using Python 3.9 version. Pillow is compatible with that but only from v8. Check your pillow version. If its below 8, update it using:

>>pip install --upgrade Pillow

Moreover, if the 2nd error still persists, try this:

from PIL import Image instead of import Image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...