Reputation: 4521
I'm trying to run Google App Engine with the PIL library & jpeg support in order to make use of the images module in GAE.
Here is what I have done so far:
I downloaded the tarball for PIL 1.1.7
and extracted it and installed it with python setup.py install
. However I noticed that the output said no jpeg support available. So I poked through the README
and learned that I need to install libjpeg.
So then I downloaded the source for jpeg-7
and built it. I configured with the following flags before I ran make
and make install
: configure --enable-shared --enable static
. I originally configured & built without these flags but I found numerous sources claiming it needs to be done to get PIL to recognize libjpeg on OSX, so I ran make clean
and make distclean
and reconfigured with the flags and rebuilt.
Then I tried to re-install PIL. I navigated to the directory where I had extracted PIL's source code. In setup.py, I changed the line JPEG_ROOT
to point to /usr/local/bin
(where jpeg had installed, but seeing that PIL wanted the libraries rather than the binaries I later repeated step 3 but with /usr/local/lib
and again with libinclude('/usr/local')
as a final attempt) and ran python setup.py clean
, python setup.py build
, and python setup.py install
. This seemed to work fine. The output claimed that there was jpeg support. However, when I fired up GAE, PIL worked fine but I couldn't get jpeg support. The output from the PIL install script is here:
--
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
But GAE claimed no jpeg support, and every time I ran python selftest.py
it gave me the following output:
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.
I am at my wit's end here. I've tried everything I can think of. I even tried pointing setup.py
straight to the uncompiled header files of jpeg-7, since the comments in setup.py
ask for the lib
and includes
directories. I simply can't figure out why PIL won't build with JPEG support. I've tried everything I can find on the internet. I seem to run into this kind of issue often when building from source. I would appreciate any and all suggestions (even suggestions on how to install PIL from a repository or something easy - I'm tired of trying to build software from source and ending up with huge messes of directories on my machine that won't compile into something nice).
Upvotes: 0
Views: 584
Reputation: 4521
I managed to figure this out. I feel a little bit embarrassed, but hopefully this will be a reference to anybody doing this in the future.
It turns out that when I ran python setup.py build
(or setup.py install
without building first, which seems to call the build script if it hasn't been run already), it wouldn't overwrite the builds that already existed, and setup.py clean
did not remove these either (though I naively assumed that the script did). I simply rm -rf *
'd everything in the PIL build/
folder, which forced PIL to start builds anew. Then finally PIL listened to me and applied the changes I made to JPEG_ROOT
, which worked after all.
Upvotes: 3