在 mingw/cygwin 上构建时如何让 PIL 工作?
我正在尝试针对 cygwin 或 mingw 构建 PIL 1.1.6,同时针对 Windows 安装的 python 运行。 当我执行任一构建工作时,但在尝试保存文件时出现以下失败。
$ python25 Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from PIL.Image import open >>> im = open('test.gif') >>> im.save('output1.gif') Traceback (most recent call last): File "", line 1, in File "c:\Python25\Lib\site-packages\PIL\Image.py", line 1405, in save save_handler(self, fp, filename) File "c:\Python25\Lib\site-packages\PIL\GifImagePlugin.py", line 291, in _save ImageFile._save(imOut, fp, [("gif", (0,0)+im.size, 0, rawmode)]) File "c:\Python25\Lib\site-packages\PIL\ImageFile.py", line 491, in _save s = e.encode_to_file(fh, bufsize) IOError: [Errno 0] Error >>>
我没有使用 jpeg 或 zip 支持的库进行编译,但我认为这与这里无关。
失败的行似乎是在encode.c 中的encode_to_file 中写入的。
我怀疑发生这种情况是因为文件描述符从 Python(在 Visual Studio 2003 下构建)传递到 _imaging.pyd,但文件描述符不匹配,因为在 Windows 上文件描述符是抽象的操作系统。 有人对这个有了解吗?
I'm trying to build PIL 1.1.6 against cygwin or mingw whilst running against a windows install of python. When I do either the build works but I get the following failure when trying to save files.
$ python25 Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from PIL.Image import open >>> im = open('test.gif') >>> im.save('output1.gif') Traceback (most recent call last): File "", line 1, in File "c:\Python25\Lib\site-packages\PIL\Image.py", line 1405, in save save_handler(self, fp, filename) File "c:\Python25\Lib\site-packages\PIL\GifImagePlugin.py", line 291, in _save ImageFile._save(imOut, fp, [("gif", (0,0)+im.size, 0, rawmode)]) File "c:\Python25\Lib\site-packages\PIL\ImageFile.py", line 491, in _save s = e.encode_to_file(fh, bufsize) IOError: [Errno 0] Error >>>
I'm not compiling with the libraries for jpeg or zip support but I don't think this should be relevant here.
The failing line seems to be a write in encode_to_file in encode.c.
I'm suspiscious that this occurs because a file descriptor is being passed from Python (which was build under visual studio 2003) to _imaging.pyd but that the file descriptors don't match because on windows file descriptors are and abstraction on top of the operating system. Does anyone know anything about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我从一些粗略的 Google 搜索中可以看出,您需要在构建 PIL 后重新设置 DLL 的基础,才能使其在 Cygwin 上正常工作。
参考文献:
http://jetfar.com/cygwin-install -python-imaging-library/
http://www.cygwin.com/ml/cygwin/2003-06/msg01121.html
As far as I can tell from some cursory Google searching, you need to rebase the DLLs after building PIL in order for it to work properly on Cygwin.
References:
http://jetfar.com/cygwin-install-python-imaging-library/
http://www.cygwin.com/ml/cygwin/2003-06/msg01121.html