Snow Leopard Python 2.6 使 PIL 工作时出现问题

发布于 2024-08-07 03:51:22 字数 638 浏览 5 评论 0原文

我安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你在我安 2024-08-14 03:51:22

我刚刚在 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, see
Universal Binaries in MacPorts as it relates to PIL dependencies.

も让我眼熟你 2024-08-14 03:51:22

当您之前从 fink 或 ports 安装了 python 工具时,从源代码编译时会发生很多此类错误。例如,当 /opt/local/lib 中有剩余的 libjpeg 文件时,可能会发生 _jpeg_resync_to_restart 错误。试试这个:

cd /opt/local/lib
sudo rm *jpeg*

然后重新编译 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:

cd /opt/local/lib
sudo rm *jpeg*

Then recompile libjpeg (starting with make clean), then recompile PIL (starting with rm -Rf build).

After that, import _imaging should work. Did for me anyway.

若水般的淡然安静女子 2024-08-14 03:51:22

编辑:感谢您添加的错误消息。这显然是雪豹上 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/

孤蝉 2024-08-14 03:51:22

我也一直遇到这个问题。事实证明,这与我在尝试修复 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文