导入 PIL,更具体地说是来自 PIL 的图像,不起作用

Importing PIL, more specifically Image from PIL, isn't working

这是我所做的描述。

我正在尝试使用 PIL 编写程序,但是在尝试导入它时(如下所示)出现错误(也如下所示)。

from PIL import Image

Here is the error.

Traceback (most recent call last):
  File "C:/Users/user/Desktop/Wook/Test Bench.py", line 1, in <module>
    from PIL import Image
  File "C:\Python\lib\site-packages\PIL\Image.py", line 56, in <module>
    from . import _imaging as core
ImportError: DLL load failed: The specified procedure could not be found.

我试过简单地 import Image:

但是,它也显示错误:

Here is the error to the second situation.

Traceback (most recent call last):
  File "C:/Users/user/Desktop/Wook/Test Bench.py", line 1, in <module>
    import Image
ModuleNotFoundError: No module named 'Image'

以下是我为解决该问题所做的努力的简短列表:

我已经试过了。如果有人能帮助我,我将不胜感激,如果需要提供任何进一步的信息,我们可以而且将会提供。

存在 Python 问题,这意味着针对 Python 3.6.1 构建的 wheel,例如 Pillow 4.1.0,将无法在 Python 3.6.0 上运行。

修复方法是更新到 Python 3.6.1,或安装 Pillow 4.0.0(针对 Python 3.6.0 构建)。

有关详细信息,请参阅: https://github.com/python-pillow/Pillow/issues/2479 https://mail.python.org/pipermail/python-dev/2017-March/147707.html https://bugs.python.org/issue29943


更新:

这影响了一些 Python 图书馆。

但是,新的 Pillow 4.1.1 版本可以解决这个问题,因此您现在可以更新到 Pillow 4.1.1 并将其与 Python 3.6.0 和 3.6.1 一起使用。