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

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

我使用 pytesseract 对图像进行 OCR。一切正常..直到我在我的 cmd 中尝试 pip install pillow 和 pip easy install pillow 只是为了尝试随机裁剪。之后,当我尝试导入 pytesseract 时。它不断抛出错误

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\pytesseract\pytesseract.py", line 28, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

在处理上述异常的过程中,又发生了异常:

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

您正在使用 Python 3.9 版本。 Pillow 与此兼容,但仅来自 v8。检查你的枕头版本。如果低于 8,请使用以下方式更新它:

>>pip install --upgrade Pillow

此外,如果第二个错误仍然存​​在,试试这个:

from PIL import Image 代替 import Image