Python imaging library Python图像库:AttributeError:';非类型';对象没有属性XXX
我用PIL打开了一张图片,但当我试图使用Python imaging library Python图像库:AttributeError:';非类型';对象没有属性XXX,python-imaging-library,Python Imaging Library,我用PIL打开了一张图片,但当我试图使用split()分割频道时,我遇到了以下错误: AttributeError:'NoneType'对象没有属性“bands” import Image img = Image.open('IMG_0007.jpg') img.split() --------------------------------------------------------------------------- AttributeError
split()
分割频道时,我遇到了以下错误:
AttributeError:'NoneType'对象没有属性“bands”
import Image
img = Image.open('IMG_0007.jpg')
img.split()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/blum/<ipython console> in <module>()
/usr/lib/python2.6/dist-packages/PIL/Image.pyc in split(self)
1495 "Split image into bands"
1496
-> 1497 if self.im.bands == 1:
1498 ims = [self.copy()]
1499 else:
AttributeError: 'NoneType' object has no attribute 'bands'
导入图像
img=Image.open('img_0007.jpg'))
img.split()
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
/home/blum/in()
/拆分中的usr/lib/python2.6/dist-packages/PIL/Image.pyc(self)
1495“将图像分割为多个波段”
1496
->1497如果self.im.bands==1:
1498 ims=[self.copy()]
1499其他:
AttributeError:“非类型”对象没有属性“带”
通过谷歌搜索,我找到了这个,打开后“忘记”加载。所以你必须这样做:
import Image
img = Image.open('IMG_0007.jpg')
img.load()
img.split()
请+1同时添加原始评论!这个人做了真正的工作。我的问题是PIL没有正确安装。当尝试读取png时,我会得到这个错误。我的汇编摘要产生了
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.3 (default, Apr 21 2012, 01:05:55)
[GCC 4.6.3]
--------------------------------------------------------------------
*** TKINTER support not available
*** JPEG support not available
*** ZLIB (PNG/ZIP) support not available <===============
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
--------------------------------------------------------------------
PIL 1.1.7设置摘要
--------------------------------------------------------------------
版本1.1.7
平台linux2 2.7.3(默认,2012年4月21日01:05:55)
[GCC 4.6.3]
--------------------------------------------------------------------
***TKINTER支持不可用
***JPEG支持不可用
***ZLIB(PNG/ZIP)支持不可用