Snow Leopard Python 2.6 使 PIL 工作时出现问题
我安装了 libjpeg 和 PIL,但是当我尝试保存 JPG 图像时,总是收到此错误:
ImportError: The _imaging C module is not安装
非常感谢任何帮助!
我尝试使用 Python 解释器导入 _imaging 来看看出了什么问题,结果是:
>>> import _imaging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so
Expected in: dynamic lookup
I installed libjpeg and PIL, but when I try to save a JPG image, I always get this error:
ImportError: The _imaging C module is not installed
Any help much appreciated!
I tried to import _imaging w/ Python interpreter to see what's wrong and got this:
>>> import _imaging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so
Expected in: dynamic lookup
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚在 SL 上也遇到了这个问题,问题可能是你的 libjpeg 是在没有匹配架构的情况下构建的。假设您使用的是 MacPorts,请运行
file /opt/local/lib/libjpeg.dylib
。正确的方法是使用 MacPorts 将所有内容构建为+universal
,请参阅MacPorts 中的通用二进制文件,因为它与 PIL 相关依赖关系。
I just hit this as well on SL, and the problem is likely your libjpeg was built without a matching architecture. Assuming you're using MacPorts, run
file /opt/local/lib/libjpeg.dylib
. The right way is to build everything with MacPorts as+universal
, seeUniversal Binaries in MacPorts as it relates to PIL dependencies.
当您之前从 fink 或 ports 安装了 python 工具时,从源代码编译时会发生很多此类错误。例如,当
/opt/local/lib
中有剩余的 libjpeg 文件时,可能会发生_jpeg_resync_to_restart
错误。试试这个:然后重新编译 libjpeg(从
make clean
开始),然后重新编译 PIL(从rm -Rf build
开始)。之后,
import _imaging
应该可以工作。无论如何,都是为我做的。A lot of these errors happen when compiling from source when you've previously installed python tools from fink or ports. For example the
_jpeg_resync_to_restart
error can happen when you've got leftover libjpeg files in/opt/local/lib
. Try this:Then recompile libjpeg (starting with
make clean
), then recompile PIL (starting withrm -Rf build
).After that,
import _imaging
should work. Did for me anyway.编辑:感谢您添加的错误消息。这显然是雪豹上 jpeglib 的问题。你试过这个吗?
http://jetfar.com/libjpeg-and-python -imaging-pil-on-snow-leopard/
Edit: Thanks for the added error message. This is apparently a problem with the jpeglib on Snow Leopard. Have you tried this?
http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/
我也一直遇到这个问题。事实证明,这与我在尝试修复 MySQLdb 安装问题时对 .bash_profile 所做的更改(强制使用 ggc-4.0)有关。
http://www.brambraakman.com/blog/comments/installing_pil_in_snow_leopard_jpeg_resync_to_restart_error/
I kept having this problem as well. It turned out to be related to a change I made to my .bash_profile (forcing the usage of ggc-4.0) when trying to fix a MySQLdb installation problem.
http://www.brambraakman.com/blog/comments/installing_pil_in_snow_leopard_jpeg_resync_to_restart_error/