在OSX上无法获得PIL的jpeg支持

时间:2013-03-19 05:54:55

标签: macos google-app-engine python-imaging-library libjpeg

我正在尝试使用PIL库运行Google App Engine& jpeg支持以便在GAE中使用images模块。

这是我到目前为止所做的:

  1. 我下载了PIL 1.1.7的tarball并将其解压缩并安装python setup.py install。但是我注意到输出表示没有jpeg支持可用。所以我浏览了README并了解到我需要安装libjpeg。

  2. 然后我下载了jpeg-7的源代码并构建了它。在我运行makemake installconfigure --enable-shared --enable static之前,我配置了以下标志。我最初配置&在没有这些标志的情况下构建但是我发现许多消息来源声称需要完成才能让PIL识别OSX上的libjpeg,所以我运行make cleanmake distclean并重新配置了标志并重建。

  3. 然后我尝试重新安装PIL。我导航到我提取PIL源代码的目录。在setup.py中,我将行JPEG_ROOT更改为指向/usr/local/bin(已安装jpeg的地方,但看到PIL需要库而不是二进制文件,我后来重复了第3步但使用了{{1} }并再次使用/usr/local/lib作为最后一次尝试)并运行libinclude('/usr/local')python setup.py cleanpython setup.py build。这似乎工作正常。输出声称有jpeg支持。然而,当我解雇GAE时,PIL工作正常,但我无法获得jpeg支持。 PIL安装脚本的输出位于:

  4. -

    python setup.py install

    但GAE声称没有jpeg支持,每次我运行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 时它都给了我以下输出:

    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. 直接指向jpeg-7的未编译头文件,因为setup.py中的注释要求setup.pylib目录。我简直无法弄清楚为什么PIL不能用JPEG支持构建。我已经尝试了我能在互联网上找到的一切。从源代码构建时,我似乎经常遇到这种问题。我会很感激任何和所有的建议(甚至建议如何从存储库安装PIL或简单的东西 - 我已经厌倦了尝试从源代码构建软件并最终在我的机器上的大量目录无法编译成好的东西)。

1 个答案:

答案 0 :(得分:3)

我设法解决了这个问题。我觉得有点尴尬,但希望这将成为未来任何人这样做的参考。

事实证明,当我运行python setup.py build(或setup.py install而没有先构建时,如果尚未运行它似乎调用构建脚本),它将不会覆盖构建已存在,setup.py clean也没有删除这些(虽然我天真地认为脚本没有)。我只是rm -rf *'在PIL build/文件夹中的所有内容,这会强制PIL重新开始构建。然后,PIL终于听取了我的意见,并将我对JPEG_ROOT所做的更改应用到了{{1}}之后。