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

James Dean james_dean at comcast.net
Fri Jan 23 14:23:42 EST 2009


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]
	- 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>

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