我正在尝试使用Python 2.6.1,GCC 4.2.1,PIL 1.1.7在Snow Leopard上安装PIL,并尝试使用libjpeg6b和libjpeg7 - 没有任何作用。我已经从fink中清除了libjpeg / pil / zlib的每一条痕迹,尝试了各种编译器选项等,并使用了http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/和http:// www.brambraakman.com/blog/comments/installing_pil_in_snow_leopard_jpeg_resync_to_restart_error/(不是链接,因为StOv只允许我发布一个...)
4位可能有用的信息:
OTOOL不会将libjpeg显示为依赖
otool -L /Library/Python/2.6/site-packages/PIL/_imaging.so
/Library/Python/2.6/site-packages/PIL/_imaging.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
我得到了这些奇怪的编译器消息
i686-apple-darwin10-gcc-4.2.1: -framework: linker input file unused because linking not done
i686-apple-darwin10-gcc-4.2.1: Tcl: linker input file unused because linking not done
i686-apple-darwin10-gcc-4.2.1: -framework: linker input file unused because linking not done
i686-apple-darwin10-gcc-4.2.1: Tk: linker input file unused because linking not done
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/sw/include/freetype2 -I/sw/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c Tk/tkImaging.c -o build/temp.macosx-10.6-universal-2.6/Tk/tkImaging.o -framework Tcl -framework Tk
In file included from /System/Library/Frameworks/Tk.framework/Headers/tk.h:78,
from Tk/tkImaging.c:51:
selftest.py由于_imagingmath而失败(在我使用上面给出的第二个链接之后,由于_imaging而失败之前)
Themistocles:Imaging-1.1.7 me$ python selftest.py
Traceback (most recent call last):
File "selftest.py", line 11, in <module>
from PIL import ImageMath
File "./PIL/ImageMath.py", line 19, in <module>
import _imagingmath
ImportError: No module named _imagingmath
除了selftest.py以外的任何内容都因为_imaging
而失败>>> import _imaging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.6/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
Referenced from: /Library/Python/2.6/site-packages/PIL/_imaging.so
Expected in: flat namespace
in /Library/Python/2.6/site-packages/PIL/_imaging.so
请帮忙!这太荒谬了。我甚至很高兴能够在此时编译PIL sans jpeg支持!
答案 0 :(得分:5)
我最近写了一篇关于如何让PIL,django,libjpeg与Snow Leopard一起工作的文章
http://appelfreelance.com/2010/06/libjpeg-pil-snow-leopard-python2-6-_jpeg_resync_to_restart/
我也会在这里为你复制。
如果您没有先下载它。
通过运行以下
进入shell环境并解压缩tar -zxvf jpegsrc.v7.tar.gz
cd jpeg-7
然后运行
sudo make clean
sudo CC =“gcc -arch i386”“./ configure --enable-shared --enable-static
sudo制作
sudo make install
接下来获取PIL并解压缩
http://effbot.org/downloads/Imaging-1.1.6.tar.gz
tar -zxvf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6
如果您已经有PIL,我建议您运行
sudo rm -Rf build
清理任何现有版本,这导致了大量错误和白发!
在您的settings.py文件中运行find JPEG_ROOT
修改它,使其如下所示
JPEG_ROOT = libinclude(“/ usr / local”)
接下来转到构建
sudo python setup.py build
如果成功安装了libjpeg,你应该可以运行python selftest.py而不会出现与“jpeg”相关的任何错误
sudo python setup.py install
如果一切顺利,您应该能够通过在命令行中执行python来输入python解释器,并执行以下操作:
导入PIL
导入图像
import _imaging
没有任何错误。
只需三重检查我的桌面上有一个简单的jpeg。
image = Image.open(“/ Users / MyName / Desktop / myimage.jpeg”)
image.save(“/用户/ MYNAME /桌面/ test.jpeg”)
应该没有错误
答案 1 :(得分:1)
下载macport:
http://www.macports.org/install.php
然后将它用于pil:
http://trac.macports.org/browser/trunk/dports/python/py-pil/Portfile
我也遇到了很多麻烦,但端口管理。
答案 2 :(得分:0)