[mod_python] PIL not working in mod_python on macosx 10.5

Graham Dumpleton graham.dumpleton at gmail.com
Wed Nov 7 03:38:31 EST 2007


On 07/11/2007, Arnaud Delobelle <delobelle at blueyonder.co.uk> wrote:
>
> On 7 Nov 2007, at 00:59, Graham Dumpleton wrote:
> >
> [...]
> > Post here what is output to the Apache error log file.
>
>
> This is the tail of error_log:
>
>         File "/Users/arno/Sites/square.py", line 43, in <module>
>                 import _imaging
>
>         ImportError: dlopen(/Library/Python/2.5/site-packages/PIL/
> _imaging.so, 2): no suitable image found.  Did find:
>         /Library/Python/2.5/site-packages/PIL/_imaging.so: no matching
> architecture in universal wrapper
> So this is as I suspected first.  But how is that as python is i386/
> ppc and so is _imaging.so?

Both Python framework and httpd on Leopard are x86_64 capable. Quoting
from previous where this was already worked out:

[Macintosh:Library/Frameworks/Python.framework] benha% file Python
Python: Mach-O universal binary with 4 architectures
Python (for architecture ppc7400): Mach-O dynamically linked shared library ppc
Python (for architecture ppc64): Mach-O 64-bit dynamically linked
shared library ppc64
Python (for architecture i386): Mach-O dynamically linked shared library i386
Python (for architecture x86_64): Mach-O 64-bit dynamically linked
shared library x86_64

[Macintosh:~/Documents/Development] benha% file /usr/sbin/httpd
/usr/sbin/httpd: Mach-O universal binary with 4 architectures
/usr/sbin/httpd (for architecture ppc7400): Mach-O executable ppc
/usr/sbin/httpd (for architecture ppc64): Mach-O 64-bit executable ppc64
/usr/sbin/httpd (for architecture i386): Mach-O executable i386
/usr/sbin/httpd (for architecture x86_64): Mach-O 64-bit executable x86_64

So, if you CPU is 64 bit then all the libraries and loadable modules
must also be 64 bit capable as Apache will run as x86_64.

This would be irrespective of whether the 'python' program itself
isn't x86_64. Ie.,

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

You just need to rebuild PIL, modifying the makefiles as necessary to
ensure that it generates a full fat binary.

For the prior discussions, go to:

  http://www.modpython.org/pipermail/mod_python/2007-October/thread.html

and look for all the Leopard threads down near the end.

I do find it awfully strange that the Python framework is fully fat
and the 'python' program isn't. Apple seems to have screwed up various
things with Apache and Python. :-(

Graham


More information about the Mod_python mailing list