2010-07-11 64 views
3

我試圖在Snow Leopard上安裝PIL,使用Python 2.6.1,GCC 4.2.1,PIL 1.1.7,並嘗試使用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讓我發佈一個......)在雪豹上安裝PIL - 沒有作品

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支持!

回答

1

下載macport:

http://www.macports.org/install.php 

然後用它來PIL:

http://trac.macports.org/browser/trunk/dports/python/py-pil/Portfile 

我也有很多的這種麻煩,但端口管理。

+0

我應該刪除我已經安裝了的libjpeg/PIL的副本? – 2010-07-11 21:23:40

+0

暫停,macports是否想要安裝它自己的Python,還是將它與系統之間的良好? – 2010-07-11 21:25:12

+0

當我運行它時,我已經安裝了較新的python,所以我不完全確定。它可能需要重新安裝一些fink已有的東西,我從來沒有聯合使用過這兩個。 – eruciform 2010-07-11 21:32:26

0

當我嘗試安裝PIL時,我總是得到幾個屏幕值得的gcc錯誤。在某些時候,我得到了一些工作(也許通過MacPorts),所以現在我的解決方案是將其複製到適當的站點包(例如在新的virtualenv中)。

我剛剛張貼在這裏:http://blogmaker.com/PIL-1.1.6-for-MacOSX-10.5-Leopard.zip

對我的作品;我不知道它是否會爲其他人工作!隨時與我聯繫的建議。而且,讓我知道我是否應該發佈一個更好的地方。 PIL既非常酷,也非常麻煩;有一個明確的支持地點將是很好的。還有其他PIL相關的問題,我從來沒有解決。

+0

通過搜索找到本文的人的更新:還有一個稱爲Pillow的PIL叉,旨在更容易安裝。請參閱http://pypi.python.org/pypi/Pillow/(我還沒有測試過,但下次我必須安裝。) – 2012-10-13 03:13:15

5

我最近寫了一篇關於如何讓PIL,Django的文章,libjpeg的並肩雪豹

http://appelfreelance.com/2010/06/libjpeg-pil-snow-leopard-python2-6-_jpeg_resync_to_restart/

的工作很好,我會在這裏複製了你。

如果你沒有這個下載它首先。

http://www.ijg.org/files/jpegsrc.v7.tar.gz

進入你的shell環境,並解壓運行以下

tar -zxvf jpegsrc.v7.tar.gz
cd jpeg-7

然後運行

sudo make clean
sudo CC="gcc -arch i386」"./configure --enable-shared --enable-static
sudo make
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文件運行

找到JPEG_ROOT

,所以它看起來的libjpeg如果安裝成功,你應該如下

JPEG_ROOT = libinclude(「/usr/local」)

下一個動作到造形

sudo python setup.py build

修改它能夠運行python selftest.py,沒有任何與「jpeg」有關的錯誤

sudo python setup.py install

如果一切很順利,你應該能夠在命令行中執行Python輸入你的Python解釋器,並執行以下操作:

import PIL
import Image
import _imaging

沒有任何錯誤。

只是三重檢查我的桌面上有一個簡單的jpeg。

image = Image.open(「/Users/MyName/Desktop/myimage.jpeg」)
image.save(「/Users/MyName/Desktop/test.jpeg」)

應不會出現錯誤的工作

+1

+11111 !!!遵循上面的說明(注意先消除先前存在的libjpeg安裝)是許多故障後最終成功的解決方案。對於其他人,我在運行selftest時也得到了'ImportError:No module named _imagingmath'。py,但它似乎並不重要,因爲最後我可以導入_imaging'而不會出現_jpeg_resync_to_restart錯誤 – Anentropic 2012-02-29 20:47:18

+0

argh,不!我仍然得到'IOError:解碼器jpeg不可用'......撕裂我的頭髮! – Anentropic 2012-02-29 20:51:46

+1

啊是的!我忘了在libjpeg上執行'sudo make install'命令,從頭開始重新啓動,現在它確實可以工作。恢復理智! – Anentropic 2012-02-29 21:04:16