【问题标题】:Error using Pillow: ImportError: cannot import name _imaging使用 Pillow 时出错:ImportError: cannot import name _imaging
【发布时间】:2015-02-14 17:23:29
【问题描述】:

我已经阅读了类似问题的答案,但似乎没有一个适合我的情况。 尝试使用 Pillow 时,出现此错误:

>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 63, in <module>
 from PIL import _imaging as core
ImportError: cannot import name _imaging

在我的 /Library/Python/2.7/site-packages 目录中,我有一个包含 Image 模块的 PIL 目录,然后我有一个包含 _imaging.c 的 Pillow-master 目录,所以我不明白为什么在 Image 中。 py 第 63 行说要从 PIL 导入 _imaging。 我也尝试从 Pillow-master 中剪切 _imaging.c 并将其粘贴到 PIL 中,但它不起作用。 尝试导入图像时,我进入了 PIL。 如果我在进入站点包时尝试导入它,它不起作用并显示“没有名为 PIL 的模块”。

【问题讨论】:

  • 您的问题解决了吗?我也遇到了同样的问题...

标签: python python-imaging-library pillow


【解决方案1】:

尝试删除您的 PIL 库并通过以下方式安装新库:

pip install PIL --allow-external PIL --allow-unverified PIL

【讨论】:

  • 我已经安装了 Pillow,你确定我也应该安装 PIL 吗?我读到它们不能共存。无论如何,如果我尝试您的命令,我会收到此错误:'命令 python setup.py egg_info failed with error code 1 in /private/var/folders/_v/6sd72pcd26j8nd87vmmmtznc0000gn/T/pip_build_MYACCOUNT/PIL 存储调试在 /Users/MYACCOUNT/.pip/pip.log' 中记录失败
  • @Mikhaylova,我没有使用 Pillow,只有 PIL。
猜你喜欢
  • 1970-01-01
  • 2019-07-04
  • 1970-01-01
  • 1970-01-01
  • 2018-10-27
  • 2019-10-24
  • 2015-09-07
相关资源
最近更新 更多