我試圖運行帶有PIL庫& jpeg支持的Google App Engine,以便使用GAE中的圖像模塊。無法在OSX上獲得對PIL的JPEG支持
這是我迄今所做的:
我下載的壓縮包爲
PIL 1.1.7
和提取,並與python setup.py install
安裝它。但是我注意到輸出表示沒有可用的jpeg支持。所以我戳穿了README
,並得知我需要安裝libjpeg。然後我下載
jpeg-7
的源代碼並構建它。我在運行make
和make install
之前配置了以下標誌:configure --enable-shared --enable static
。我最初配置&沒有這些標誌建成,但我發現許多消息來源聲稱它需要做到讓PIL識別OSX上的libjpeg,所以我跑了make clean
和make distclean
並重新配置了標誌並重建。然後我試着重新安裝PIL。我導航到了我已經提取PIL源代碼的目錄。在setup.py中,我將行
JPEG_ROOT
更改爲指向/usr/local/bin
(其中已安裝了jpeg,但看到PIL需要這些庫,而不是我後來重複步驟3的二進制文件,但是/usr/local/lib
和libinclude('/usr/local')
作爲最終嘗試)並運行python setup.py clean
,python setup.py build
和python setup.py install
。這似乎工作正常。輸出聲稱有JPEG支持。但是,當我啓動GAE時,PIL工作正常,但我無法獲得jpeg支持。從PIL安裝腳本的輸出是在這裏:
-
Jays-MacBook-Air:Imaging-1.1.7 jay$ python setup.py install
running install
running build
running build_py
running build_ext
gcc-4.2 not found, using clang instead
--- using frameworks at /System/Library/Frameworks
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
To check the build, run the selftest.py script.
running build_scripts
running install_lib
running install_scripts
changing mode of /Library/Frameworks/Python.framework/Versions/2.7/bin/pilconvert.py to 755
changing mode of /Library/Frameworks/Python.framework/Versions/2.7/bin/pildriver.py to 755
changing mode of /Library/Frameworks/Python.framework/Versions/2.7/bin/pilfile.py to 755
changing mode of /Library/Frameworks/Python.framework/Versions/2.7/bin/pilfont.py to 755
changing mode of /Library/Frameworks/Python.framework/Versions/2.7/bin/pilprint.py to 755
running install_egg_info
Removing /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/PIL-1.1.7-py2.7.egg-info
Writing /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/PIL-1.1.7-py2.7.egg-info
creating /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL.pth
但GAE聲稱不支持JPEG,每次我跑python selftest.py
時間它給了我下面的輸出:
Jays-MacBook-Air:Imaging-1.1.7 jay$ python selftest.py
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
*** JPEG support not installed
--- ZLIB (PNG/ZIP) support ok
*** FREETYPE2 support not installed
*** LITTLECMS support not installed
--------------------------------------------------------------------
Running selftest:
*****************************************************************
Failure in example:
try:
_info(Image.open(os.path.join(ROOT, "Images/lena.jpg")))
except IOError, v:
print v
from line #24 of selftest.testimage
Expected: ('JPEG', 'RGB', (128, 128))
Got: decoder jpeg not available
1 items had failures:
1 of 57 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.
我在我的智慧結束在這裏。我試過了我能想到的一切。我甚至試着將setup.py
直接指向jpeg-7的未編譯頭文件,因爲setup.py
中的註釋要求lib
和includes
目錄。我簡直無法弄清楚爲什麼PIL不能用JPEG支持構建。我嘗試了所有可以在互聯網上找到的東西。從源代碼構建時,我似乎經常遇到這種問題。我將不勝感激任何和所有的建議(甚至是關於如何從存儲庫安裝PIL的建議或簡單的東西 - 我厭倦了試圖從源代碼構建軟件,並結束了我的機器上大量的無法編譯的目錄好東西)。
'import PIL的輸出是什麼; PIL .__ FILE__「?是否與您使用jpeg支持安裝PIL的地方相同? – 2013-03-19 06:03:46
另外,你有沒有考慮過使用macports,它可以讓你調用'sudo port install py27-pil'?但這不是一個直接的解決方案。 – 2013-03-19 06:08:05
隆 - 是的,他們是一樣的。在交互式Python會話中運行'import PIL'工作得很好(當然除了jpeg支持)。我已經考慮過使用Macports,儘管我確實設法讓所有的東西都能正常工作(請參閱下面我自己的答案)。我認爲這些日子裏有一個我需要構建的所有這些軟件,我不妨將其吸收並安裝MacPorts。 – jayhendren 2013-03-19 06:14:20