[mod_python] mod_python.so: undefined symbol: ap_loaded_modules

Jim Gallacher jpg at jgassociates.ca
Wed Nov 16 12:46:31 EST 2005


Mark Dokter wrote:
> On Wednesday 16 November 2005 05:25, Graham Dumpleton wrote:
> 
> 
>>A random bit of information that may not be relevant, but if you have
>>multiple versions of Python installed and the one which is first in your
>>PATH is not the same one as mod_python was built for, and you run
>>"apachectl restart" or "apachectl start" explicitly, mod_python can fail
>>because it will use the one found in PATH and not the one it was built
>>for.
>>
> 
> 
> I followed the FAQ to check the mod_python version:
> Set sys.path to 
> 
>>>>sys.path
> 
> ['/usr/lib/python2.3/site-packages', '/usr/lib/python2.3', ...]
> 
> When importing mod_python.psp this gabe me:
> 
>>>>import mod_python.psp
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 20, in ?
>     import apache, Session, util, _psp
>   File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 28, in ?
>     import _apache
> ImportError: No module named _apache

That's good and it's what we expect. That means *python* can find the 
mod_python modules. The _apache module is only available in a python 
interpreter running in the Apache server module so we expect that import 
to fail from the command line. If the python command line interpreter 
couldn't find the mod_python modules you'd see "ImportError: No module 
named mod_python".

> According to the FAQ this should be version 3.1 (as apt already told me)
> 
> I set the PythonPath variable in /etc/apache2/mods-enabled/mod_python.conf 
> like this:
> 
> PythonPath "['/usr/lib/python2.3','/usr/lib/python2.3/site-packages',
> [/usr/lib/apache2/modules']"

Wrong. /etc/apache2/mods-enabled contains symbolic links to 
/etc/apache2/mods-available which in turn contains Apache configuration 
files. These files hold directives for loading *Apache* modules. This 
has nothing to do with the python modules in site-packages/mod_python. 
/usr/lib/apache2/modules does *NOT* belong on your PythonPath.

On Debian:

/etc/apache2/mods-enabled/mod_python.conf should be a symbolic link to
/etc/apache2/mods-available/mod_python.conf.

/etc/apache2/mods-available/mod_python.conf should contain:

LoadModule python_module /usr/lib/apache2/modules/mod_python.so

This tells the server to load the *Apache* module mod_python.so. *Do 
not* confuse this Apache module with the stuff in 
site-packages/mod_python. It is not the same thing. mod_python.so 
contains the magic that embeds the python interpreter into apache.

> But I still get this in the log file:
> [Wed Nov 16 16:06:42 2005] [error] make_obcallback: could not import 
> mod_python.apache.\n
> 
> 
> 
>>The reason for failure can be because the one found doesn't have the
>>mod_python Python code components installed for it, or it has a
>>different version mod_python Python code components which are
>>incompatible.
>>
> 
> 
> I have the same package versions installed on another Debian system where it 
> works. So there must be something wrong with the configuration. The faulty 
> system was set up by someone else a while ago. There is 
> a /usr/lib/python2.2, /usr/lib/python2.4 and a /usr/local/python2.3. But 
> according to my PATH settings only /usr/lib/python2.3 is used. mod_python is 
> installed in /usr/lib/python2.3/site-packages/mod_python.

What do the first 2 lines of /var/log/apache2/error.log show after an 
Apache restart? They should look something like this:

[Wed Nov 16 12:24:07 2005] [notice] mod_python: Creating 8 session 
mutexes based on 50 max processes and 0 max threads.
[Wed Nov 16 12:24:07 2005] [notice] Apache/2.0.54 (Debian GNU/Linux) 
DAV/2 SVN/1.2.0 mod_python/3.2.5-dev-20051112 Python/2.3.5 PHP/4.4.0-1 
configured -- resuming normal operations

Also check the output of the following command:
   ldd /usr/lib/apache2/modules/mod_python.so |grep python

Which on my system yields:
   libpython2.3.so.1.0 => /usr/lib/libpython2.3.so.1.0 (0xb7e61000)

Jim


More information about the Mod_python mailing list