[mod_python] "Can't locate API module structure" on OS/X Leopard

Graham Dumpleton graham.dumpleton at gmail.com
Fri Jan 23 20:28:50 EST 2009


2009/1/24 James Dean <james_dean at comcast.net>:
> Thanks for your reply, Graham.  Mostly it encouraged me to keep trying!  :-)
> Briefly: I got mod_python working by running apache2 in 32-bit mode -
> details below.
>
> I didn't mention that I had also struggled a lot with mod_wsgi.  I tried it
> again after your suggestion,
> and I tried many combinations, but I could not get past having one of the
> two problems:
> - LONG_BIT definition appears wrong [at compile time]

Then you are using broken MacPorts Python or gcc installation which
isn't fully fat compatible.

> - no suitable image found [at runtime]
>
>
> Anyway, I finally found some advice here (thx mjtnix)
> http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
> The suggestion being that there was a way to run apache in 32 bit mode, and
> thus avoid these 64-bit issues.
> - Since I already built mysql for 32 bit, and due to my situation, this is
> acceptable for me
>
> mjtnix's suggestion was:
>
> I was able to force apache on leopard to run in 32-bit mode as follows.
>
> in /System/Library/LaunchDaemons?/org.apache.httpd.plist add these three
> arguments the start of the <ProgramArguments> array:
>
> <string>/usr/bin/arch</string> <string>-arch</string> <string>i386</string>

Also see:

  http://gidden.net/tom/2008/06/30/mysql-and-pdo-on-os-x-leopard-intel/

Rather than modify original plist file, you can apparently copy it to
different location and modify it there.

Was looking at updating mod_wsgi documentation about doing it this was
as modifying original will mean it gets overwritten if Apache updated
by OS updates.

Graham

> the resulting apache command line looks like this:
>
> /usr/bin/arch -arch i386 /usr/sbin/httpd -D FOREGROUND
>
> ----------------------- end mjtnix suggestion ----------------
> After doing that.
> - I first made sure apache would run without mod_python.
> - At first it would not.
> - I adjusted the suggestion to my platform, ie change i386 to ppc (duh)
> - That worked.
> - Then added in mod_python, and it worked!!
> :-)
> - jcd
>
>
>
> On Jan 23, 2009, at 8:05 AM, Graham Dumpleton wrote:
>
> If you are trying to run a Python web application or framework which
> supports WSGI, such as Django or Trac, use mod_wsgi instead and you
> may find things simpler.
>
> If not, then try mod_python from subversion repository instead as that
> definitely has correct flags.
>
>  svn co https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk
> mod_python-trunk
>
> Graham
>
> 2009/1/23 James Dean <james_dean at comcast.net>:
>
> Hello,
>
> I have looked through many emails on this subject, and tried the
>
> suggestions, but I still can't get mod_python loaded into Apache2 in OS/X
>
> Leopard.
>
> I am trying to start up apache2, with mod_python, and I am getting this
>
> error:
>
> ======================= Here is the error: =======================
>
> c-24-61-41-158:apache2 root# httpd -t
>
> httpd: Syntax error on line 124 of /private/etc/apache2/httpd.conf: Can't
>
> locate API module structure `python_module' in file
>
> /usr/libexec/apache2/mod_python.so: dlsym(0x1002091e0, python_module):
>
> symbol not found
>
> ===================== Hardware, OS ============================
>
> I have:
>
>       - powerPC Mac G5
>
>       - OS/X 10.5.6
>
> ====================== So Far ================================
>
> I was able to get past the "no suitable image found" errors, by adding
>
> additional compile
>
> and link flags, as shown below.
>
> ======================= LoadModule ========================
>
> Here is my LoadModule statement:
>
> LoadModule python_module /usr/libexec/apache2/mod_python.so
>
> ======================= Flags ===============================
>
> I took advice from other emails and set some flags in src/makefile.  Here is
>
> what I am using:
>
> INCLUDES=-I/Software/mod_python_3_3_1/mod_python-3.3.1/src/include
>
> -I/usr/include/\
>
> apache2
>
> -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
>
> LIBS=-lm  -framework  Python    -ldl
>
> CPPFLAGS =
>
> -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/pyth\
>
> on2.5 -DNDEBUG -DMACOSX -DENABLE_DTRACE
>
> LDFLAGS= -Wl,-framework,Python  -u _PyMac_Error
>
> $(PYTHONFRAMEWORKDIR)/Versions/$(V\
>
> ERSION)/$(PYTHONFRAMEWORK)  -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g
>
> -arch ppc\
>
> 7400 -arch ppc64
>
> OPT= -Wc,'-arch ppc64' -Wc,'arch ppc7400' -Wl,'-arch ppc7400' -Wl,'-arch
>
> ppc64'
>
> CFLAGS=$(OPT) $(INCLUDES)
>
> LDLIBS= -ldl
>
> ======================= Also Tried ======================
>
> I just tried this, at someone's suggestion, but it did not help:
>
> c-24-61-41-158:apache2 root# export DYLD_FORCE_FLAT_NAMESPACE
>
> ======================== Mysql, Apache, mod_python  =====================
>
> mod_python 3.3.1
>
> 50 / > file /usr/libexec/apache2/mod_python.so
>
> /usr/libexec/apache2/mod_python.so: Mach-O universal binary with 2
>
> architectures
>
> /usr/libexec/apache2/mod_python.so (for architecture ppc7400):  Mach-O
>
> bundle ppc
>
> /usr/libexec/apache2/mod_python.so (for architecture ppc64):    Mach-O
>
> 64-bit bundle ppc64
>
> mysql 5.0.51b
>
> 52 / > file /usr/local/mysql/bin/mysqld
>
> /usr/local/mysql/bin/mysqld: Mach-O executable ppc
>
> apache 2.2.9
>
> c-24-61-41-158:apache2 root# 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
>
>
> Any help would be greatly appreciated!
>
> Thank you,
>
> - Jim
>
>
>
>
>
> _______________________________________________
>
> Mod_python mailing list
>
> Mod_python at modpython.org
>
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>


More information about the Mod_python mailing list