我正在尝试使用 PIL 库和 jpeg 支持运行 Google App Engine,以便使用 GAE 中的图像模块。
这是我到目前为止所做的:
我下载了 tarball
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
andincludes
目录。我根本不明白为什么 PIL 不能使用 JPEG 支持来构建。我已经尝试了所有可以在互联网上找到的东西。从源代码构建时,我似乎经常遇到这种问题。我将不胜感激任何和所有建议(甚至是关于如何从存储库安装 PIL 或其他简单的建议 - 我厌倦了尝试从源代码构建软件并最终在我的机器上出现大量无法编译的目录好东西)。