【问题标题】:ModuleNotFoundError: No module named 'PIL' ,During handling of the above exception, another exception occurred:ModuleNotFoundError: No module named 'PIL' ,在处理上述异常的过程中,发生了另一个异常:
【发布时间】:2021-01-12 12:52:03
【问题描述】:

我使用 pytesseract 从图像中进行 OCR。一切工作正常.. 直到我在我的 cmd 中尝试了 pip install 枕头和 pip easy install 枕头,只是为了尝试随机裁剪。之后,当我尝试导入 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 python-imaging-library ocr python-tesseract modulenotfounderror


    【解决方案1】:

    您使用的是 Python 3.9 版本。 Pillow 与它兼容,但仅来自 v8。检查您的枕头版本。如果低于 8,请使用以下命令更新:

    &gt;&gt;pip install --upgrade Pillow

    此外,如果第二个错误仍然存​​在,请尝试以下操作:

    from PIL import Image 代替 import Image

    【讨论】:

    • 谢谢兄弟。我先卸载了枕头,然后使用 >>pip install --upgrade Pillow 。现在解决了
    • @Rahul Ramesh 很高兴知道它解决了您的问题?....如果您觉得它有帮助,请考虑点赞,以帮助更多人注意到它。见google.com/url?sa=t&source=web&rct=j&url=https://…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-14
    • 2019-09-25
    • 1970-01-01
    • 1970-01-01
    • 2022-06-12
    • 1970-01-01
    相关资源
    最近更新 更多