[mod_python] Solution to make_obcallback() import problems.

pday at UVic.CA pday at UVic.CA
Thu Jun 28 16:36:00 EST 2001


Hi all,

I'm fairly new to mod_python stuff and have been pouring through the list
archives and docs looking for a solution.

My setup has more than one python installation. I have stock 1.52,
2.0 and 2.1 versions on my system all of which have threads compiled
in. So I merrily compiled and installed python under my apache
directory which did not have threads. I suspect this is similar for many
of you out there.

This leads to the dreaded:
 make_obcallback(): could not import mod_python.apache.

For a while I relied on PYTHONHOME being set to the mod_python specific
area but this broke all my legacy CGI's that depended on the other
installations of python. So in a desparate measure I came up with the
following patch:

55a56,60
> /* Where the python executeable is stored. This solves the:
>  * make_obcallback(): could not import mod_python.apache.
>  * problem */
> static char* programName = "/usr/local/apache_1.3.20/bin/python";
>
273a279,281
>        /* Set where the executeable of the interpreter is */
>        Py_SetProgramName(programName);
>

This is for version 2.7.5 mod_python.c. You'll have to change programName
according to your installation. It makes sure that Py_SetProgramName is
called before Py_Initialize(). Once that's done the cryptic import errors
will vanish.

I admit this is a total hack and needs some work for official inclusion.
(ie. it would be nice is configure set programName for us automatically.)

Anyhow that's my 2 cent contibution.

Patrick.

PS:

Thanks to Mike Bell for the editting src/Makefile and change OPT=
to OPT=-DEAPI fix.

Also thanks to Damjan Georgievski for his patch to mod_python. It was
great for showing that sys.path was a mess.




More information about the Mod_python mailing list