C.B*_*uhl 18 python python-imaging-library python-2.7
我收到错误:
---------------------------------------------------------------------------
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
Run Code Online (Sandbox Code Playgroud)
每当我尝试使用PIL库时.我正在尝试加载和处理一堆.gif文件,而我现在正在尝试的是以下内容:
from PIL import Image
Run Code Online (Sandbox Code Playgroud)
尝试不同的方法,通过scipy:
import scipy.ndimage as spnd
os.chdir('C:\\WeatherSink\\data\\')
spnd.imread('2014-11-03-0645.gif')
Run Code Online (Sandbox Code Playgroud)
失败:
---------------------------------------------------------------------------
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.
Run Code Online (Sandbox Code Playgroud)
第一种方法指导我安装PIL版本.我尝试模拟getattr(...),并返回None.所以我并不感到意外,因为它不如功能.但有谁知道如何'修复'错误?
我在win7上运行,通过conda管理python2.7.我也尝试删除并重新安装软件包,输出没有任何变化.
非常感谢帮助.
aib*_*net 19
这只是一个安装问题.
如果未安装,请先在系统上安装pip.它也适用于Windows.
升级你的numpy,pip/pillow,scipy:
pip install -U numpy
pip install -U pil/pillow
pip install -U scipy
Run Code Online (Sandbox Code Playgroud)
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]]
Run Code Online (Sandbox Code Playgroud)
小智 9
这是python 3.6编辑文件中的问题:C:\Anaconda\lib\site-packages\PIL\Image.py
并更改代码:
if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
raise ImportError("The _imaging extension was built for another "
" version of Pillow or PIL")
Run Code Online (Sandbox Code Playgroud)
改为:
if core.PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
raise ImportError("The _imaging extension was built for another "
" version of Pillow or PIL")
Run Code Online (Sandbox Code Playgroud)
这将解决问题.问候
| 归档时间: |
|
| 查看次数: |
20266 次 |
| 最近记录: |