[mod_python] PIL not working in mod_python on macosx 10.5

Graham Dumpleton graham.dumpleton at gmail.com
Tue Nov 6 19:59:15 EST 2007


On 07/11/2007, Arnaud Delobelle <delobelle at blueyonder.co.uk> wrote:
> Hi
>
> First thanks to Graham for pointing me in the right direction so that
> I was able to install mod_python on macosx 10.5.  Unfortunately I have
> run into another hitch:  the PIL (Python Imaging Library) is not
> working from within mod_python, even though it is working from command-
> line python:
>
> If I create a new image from mod_python, I get the error "The _imaging
> C module is not installed".
> The module _imaging.so is in /Library/Python/2.5/site-packages/PIL/
> _imaging.so and I have checked that /Library/Python/2.5/site-packages/
> PIL/ is present in sys.path from within mod_python.
>
> I am now unable to progress any further... When I first unsuccessfully
> installed mod_python, the problem was that it compiled as an i386
> module whereas httpd is x86_64 on macosx 10.5 (on Intel Core 2 Duo).
> My first reaction was that _imaging.so was for the wrong architecture
> as well:
>
> marigold:~ arno$ file /Library/Python/2.5/site-packages/PIL/_imaging.so
> /Library/Python/2.5/site-packages/PIL/_imaging.so: Mach-O universal
> binary with 2 architectures
> /Library/Python/2.5/site-packages/PIL/_imaging.so (for architecture
> i386):  Mach-O bundle i386
> /Library/Python/2.5/site-packages/PIL/_imaging.so (for architecture
> ppc7400):       Mach-O bundle ppc
>
> But on the other hand, the same goes for python:
>
> marigold:~ arno$ file `which python`
> /usr/bin/python: Mach-O universal binary with 2 architectures
> /usr/bin/python (for architecture ppc7400):     Mach-O executable ppc
> /usr/bin/python (for architecture i386):        Mach-O executable i386
>
> Having no understanding of how mod_python works, I can't decide if
> this is the problem or not (forcing httpd to run as an i386 process
> would probably tell me the answer, but I don't know how to).  But if
> it is not, what prevents _imaging.so from loading?

There is most likely an error message getting output as to why from
mod_python internals or the OS, but unfortunately mod_python is
deficient in not promptly flushing any output to sys.stderr. Such
messages may only get flushed when Apache is shut down, so shutdown
Apache and look near end of log files for any strange messages.

Also suggest you construct a simple hello world test handler that
doesn't use any third party packages. Once that is working, add:

  import sys

  try:
    print >> sys.stderr, '#1"
    sys.stderr.flush()
    import _imaging
    print >> sys.stderr, '#2"
    sys.stderr.flush()
  except:
    print >> sys.stderr, '#3"
    sys.stderr.flush()
    raise

Post here what is output to the Apache error log file.

Graham


More information about the Mod_python mailing list