【问题标题】:PIL and pillow. ImportError: cannot import name '_imaging'PIL 和枕头。 ImportError:无法导入名称“_imaging”
【发布时间】:2021-05-17 18:31:36
【问题描述】:

跑步

from PIL import Image
import pytesseract as pt

text = pt.image_to_string(Image.open("text.png"))

给我

Traceback (most recent call last):
  File "C:\Users\Rasmus\workspace\PythonMTGO\src\OCR.py", line 1, in <module>
    from PIL import Image
  File "C:\Users\Rasmus\AppData\Local\Programs\Python\Python35\lib\site-packages\PIL\Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'

我从 https://pypi.python.org/pypi/Pillow/3.0.0 为 python 3.5 安装了枕头

我看了一个回答说 PIL 和枕头不能一起工作?但是,如果我使用 windows msi 安装程序从上面的链接安装,它将安装 PIL 和枕头并将其放入 C:\Users\Rasmus\AppData\Local\Programs\Python\Python35\Lib\site-packages

我花了一整天的时间来编写 3 行代码。希望任何人都知道可能出了什么问题。

【问题讨论】:

    标签: python


    【解决方案1】:

    你的枕头是什么版本的,

    Pillow >= 2.1.0 不再支持“import _imaging”。请使用“从 PIL.Image import core as _imaging”。

    这是官方文档

    https://pillow.readthedocs.io/en/5.1.x/installation.html#warnings

    【讨论】:

      【解决方案2】:

      卸载和安装枕头 大多数情况下这将解决这个问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-10-10
        • 2021-03-07
        • 2019-12-03
        • 2020-12-01
        • 1970-01-01
        • 2023-02-09
        • 1970-01-01
        • 2021-08-31
        相关资源
        最近更新 更多