/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h>
^ 1 error generated. error: command 'cc' failed with exit status 1
# create these links, if already exists, remove it and re-link it ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
# reinstall PIL pip uninstall PIL pip install PIL
错误
1 2
python PIL bug: NoneType object has no attribute bands
方法
在使用 python PIL 获取分量的时候出现了错误
1 2
r,g,b,a = image.split()
1 2
'NoneType' object has no attribute 'bands'
原因是图片遇到 mode 为 RGBA 的时候会出现这个问题。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
vim /usr/local/lib/python2.7/dist-packages/PIL/Image.py
定位到1501 行 1494 def split(self): 1495 "Split image into bands" 1496 1497 self.load() # 1498 if self.im.bands == 1: 1499 ims = [self.copy()] 1500 else: 1501 #self.load() 1502 ims = [] 1503 for i in range(self.im.bands): 1504 ims.append(self._new(self.im.getband(i))) 1505 return tuple(ims)