gpt4 book ai didi

python - PIL : ImportError: The _imaging extension was built for another version of pillow or PIL

转载 作者:IT老高 更新时间:2023-10-28 21:08:55 33 4
gpt4 key购买 nike

我得到错误:

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-0f6709e38f49> in <module>()
----> 1 from PIL import Image

C:\Anaconda\lib\site-packages\PIL\Image.py in <module>()
61 from PIL import _imaging as core
62 if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
---> 63 raise ImportError("The _imaging extension was built for another "
64 " version of Pillow or PIL")
65

ImportError: The _imaging extension was built for another version of Pillow or PIL

每当我尝试使用 PIL 库时。我正在尝试加载和处理一堆 .gif,而我现在正在尝试的是以下内容:

from PIL import Image

通过 scipy 尝试不同的方法:

import scipy.ndimage as spnd
os.chdir('C:\\WeatherSink\\data\\')
spnd.imread('2014-11-03-0645.gif')

失败:

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-23c383b79646> in <module>()
1 os.chdir('C:\\WeatherSink\\data\\')
----> 2 spnd.imread('2014-11-03-0645.gif')

C:\Anaconda\lib\site-packages\scipy\ndimage\io.pyc in imread(fname, flatten, mode)
36 from PIL import Image
37 except ImportError:
---> 38 raise ImportError("Could not import the Python Imaging Library (PIL)"
39 " required to load image files. Please refer to"
40 " http://pypi.python.org/pypi/PIL/ for installation"

ImportError: Could not import the Python Imaging Library (PIL) required to load image files. Please refer to http://pypi.python.org/pypi/PIL/ for installation instructions.

第一种方法引导我了解已安装的 PIL 版本。我尝试模拟 getattr(...),然后返回 None。因此,我对它的功能不足并不感到惊讶。但是有人知道如何“修复”这些错误吗?

我在win7上运行,通过conda管理python2.7。我也尝试删除并重新安装这些软件包,但输出没有任何变化。

非常感谢您的帮助。

最佳答案

这只是一个安装问题。

如果未安装 pip,请先在系统上安装它。是available for Windows also .

升级你的 numpy、pip/pillow、scipy:

pip install -U numpy
pip install -U pil/pillow
pip install -U scipy

Windows 的最佳选择是使用 anaconda .

我认为 pip 已经安装在 conda 中。这将解决您的系统版本问题。

In [1]: from PIL import Image

In [2]: import scipy.ndimage as spnd

In [3]: x = spnd.imread('ppuf100X91.gif')

In [4]: print x
[[255 255 255 ..., 255 255 255]
[255 255 255 ..., 255 255 255]
[255 255 255 ..., 255 255 255]
...,
[255 255 255 ..., 255 255 255]
[255 255 255 ..., 255 255 255]
[255 255 255 ..., 255 255 255]]

关于python - PIL : ImportError: The _imaging extension was built for another version of pillow or PIL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26720968/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com