我正在使用OS X 10.6.7、Python 2.6运行一款小型的wxPython应用程序,它使用PIL来处理图像并添加一些文本。
在尝试让PIL与libjpeg和PIL一起运行时出现了一些配置问题后,我遵循了这个网站上的说明。
当我从Imaging-1.1.7文件夹内运行python setup.py build_ext -i
命令时,我收到以下消息:
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available
--------------------------------------------------------------------
此外,在Imaging-1.1.7安装文件夹中运行python selftest.py
,我得到以下结果:
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
--- LITTLECMS support ok
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.
然而,在我的代码中渲染第一张PIL图像时,仍然会出现以下错误:
File "/Library/Python/2.6/site-packages/PIL/Image.py", line 1290, in resize self.load()
File "/Library/Python/2.6/site-packages/PIL/ImageFile.py", line 215, in load raise_ioerror(e)
File "/Library/Python/2.6/site-packages/PIL/ImageFile.py", line 52, in raise_ioerror
raise IOError(message + " when reading image file")
IOError: broken data stream when reading image file
我有些不知道接下来该尝试什么,有什么想法吗?导致这个崩溃的代码似乎是:
try:
self.img = self.img.resize((self.screenwidth, self.screenheight),
Image.ANTIALIAS)
except IOError, e:
print "Error resizing: " + str(e)
self.img = self.img.resize((self.screenwidth, self.screenheight))
raise