我知道错误:
---------------------------------------------------------------------------
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
尝试一种不同的方法,通过参与:
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。我已经尝试删除和重新安装包以及,没有任何改变的输出。
帮助是非常感谢的。
发布于 2015-01-06 17:47:46
这只是一个安装问题。
首先,如果没有安装,请在系统上安装pip。是也可用于Windows。
升级你的矮胖,皮普/枕头,枕:
pip install -U numpy
pip install -U pil/pillow
pip install -U scipy
Windows的最佳选择是使用蟒蛇。
我想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]]
发布于 2017-05-05 12:28:35
这是python3.6编辑文件:C:\Anaconda\lib\site-packages\PIL\Image.py
和change代码中的一个问题:
if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
raise ImportError("The _imaging extension was built for another "
" version of Pillow or PIL")
将其改为:
if core.PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
raise ImportError("The _imaging extension was built for another "
" version of Pillow or PIL")
这将解决问题。问候
发布于 2014-12-31 22:16:49
可能您的依赖项之一需要PIL,而PIL最终安装在Pillow之后,从而导致站点包dir中的冲突。我假设您看到了这个错误,因为导入语句是从合法的PIL安装而不是枕头安装导入_imaging
的。
我曾经有过麻烦,在过去的冲突包,需要PIL或枕头。当然,枕头是首选的包装。我想看看包的依赖关系。如果你能找到一个依赖于PIL,我会提交一个拉请求,它改变依赖的枕头,甚至可能创建您自己的叉子与该改变。就我的情况而言,分叉是我决定的选择,因为这个项目似乎已经很长时间没有活动了。
最终,您希望消除对PIL包的任何依赖(因为它不再是活动的),以支持Pillow。
https://stackoverflow.com/questions/26720968
复制相似问题