[mod_python] Trouble loading mod_python Mac Os X

Graham Dumpleton graham.dumpleton at gmail.com
Wed Jul 30 21:55:13 EDT 2008


If you still haven't sorted this, check out latest source code from:

  https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk

This incorporates all the correct MacOSX fat binary changes.

If that doesn't work then post specific issues you have with that version.

Graham

2008/7/28 Alex Lurthu <alex.lurthu at yahoo.com>:
> Hi All,
>
> I have been trying to add mod_python module to apache2. The first road block
> that i hit was :
>
> httpd: Syntax error on line 116 of /private/etc/apache2/httpd.conf: Cannot
> load /usr/libexec/apache2/mod_python.so into server:
> dlopen(/usr/libexec/apache2/mod_python.so, 10): no suitable image found.
> Did find:\n\t/usr/libexec/apache2/mod_python.so: mach-o, but wrong
> architecture
>
> To solve this i add the following lines to the Makefile under src directory
> :
>
> CPPFLAGS =
> -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
> -DNDEBUG -DMACOSX -DENABLE_DTRACE
> CFLAGS =  -Wc,'-arch ppc7400' -Wc,'-arch ppc64' -Wc,'-arch i386' -Wc,'-arch
> x86_64'
> LDFLAGS =  -arch ppc7400 -arch ppc64 -arch i386 -arch x86_64
> -Wl,-F/System/Library/Frameworks -framework Python -u _PyMac_Error
> -framework Python
> LDLIBS = -ldl
>
> It got complied with the required format or platform support.
>
> sh-3.2# file /usr/libexec/apache2/mod_python.so
> /usr/libexec/apache2/mod_python.so: Mach-O universal binary with 4
> architectures
> /usr/libexec/apache2/mod_python.so (for architecture ppc):    Mach-O bundle
> ppc
> /usr/libexec/apache2/mod_python.so (for architecture ppc64):    Mach-O
> 64-bit bundle ppc64
> /usr/libexec/apache2/mod_python.so (for architecture i386):    Mach-O bundle
> i386
> /usr/libexec/apache2/mod_python.so (for architecture x86_64):    Mach-O
> 64-bit bundle x86_64
>
> After this step, when i tried LoadModule in the httpd.conf file i got the
> following error.
>
> httpd: Syntax error on line 117 of /private/etc/apache2/httpd.conf: Can't
> locate API module structure `python_module' in file
> /usr/libexec/apache2/mod_python.so: dlsym(0x100216ae0, python_module):
> symbol not found
>
> Stuck at this point. Have a working wsgi module, but still wondering why
> this is loading. Ensured that it got built against the correct apache
> libraries and python libraries.
>
> The following are the versions that i use :
>
> Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
> sh-3.2# apachectl -v
> Server version: Apache/2.2.8 (Unix)
> Server built:   Mar  4 2008 21:37:02
>
> Platform : sh-3.2# uname -a
> Darwin sickreturn-lm 9.4.0 Darwin Kernel Version 9.4.0: Mon Jun  9 19:30:53
> PDT 2008; root:xnu-1228.5.20~1/RELEASE_I386 i386
>
> Hardware : Apple Macbook Pro (Intel 32 bit )
>
> Output of otool pasted at the end. Thanks for the help.
>
> --
> Alex
> http://alexlurthu.wordpress.com
> sh-3.2# otool -l /usr/libexec/apache2/mod_python.so
> /usr/libexec/apache2/mod_python.so:
> Load command 0
>       cmd LC_SEGMENT
>   cmdsize 328
>   segname __TEXT
>    vmaddr 0x00000000
>    vmsize 0x00016000
>   fileoff 0
>  filesize 90112
>   maxprot 0x00000007
>  initprot 0x00000005
>    nsects 4
>     flags 0x0
> Section
>   sectname __text
>    segname __TEXT
>       addr 0x00001358
>       size 0x00011f4c
>     offset 4952
>      align 2^2 (4)
>     reloff 0
>     nreloc 0
>      flags 0x80000400
>  reserved1 0
>  reserved2 0
> Section
>   sectname __cstring
>    segname __TEXT
>       addr 0x000132a4
>       size 0x00002caa
>     offset 78500
>      align 2^2 (4)
>     reloff 0
>     nreloc 0
>      flags 0x00000002
>  reserved1 0
>  reserved2 0
> Section
>   sectname __const
>    segname __TEXT
>       addr 0x00015f50
>       size 0x000000a0
>     offset 89936
>      align 2^4 (16)
>     reloff 0
>     nreloc 0
>