[mod_python] example test fails-- how to convince apache to search the correct path for python modules?

polygnwnd polygnwnd at yahoo.com
Tue Jul 24 20:20:06 EST 2001


Well, I am interested in mod_python, but am having a
hard time getting it to work. I notice
that my specific problem has come up on both Windows
and Linux and I cannot find a working
solution in the mail archives (maybe I overlooked
something?). 

What I "know"...

Platform: Linux 2.4 kernel, atop old, but vanilla
Debian

All packages used here are installed below
/home/polygnwnd/httpd:
  Python: python/2.0.1/(bin, lib, etc.)
  Apache: apache/1.3.20/(bin,libexec, etc.)

Configured options:
  Python: --without-threads
  Apache: --enable-module=rewrite
--enable-shared=rewrite
  mod_python:
--with-apxs=/home/polygnwnd/httpd/apache/1.3.20/bin/apxs
\
             
--with-python=/home/polygnwnd/src/httpd/python/2.0.1
              # I pointed with-python to the python
src build dir, makes configure happy

An strace on the httpd process reveals many
unsuccessful attempts to access
the system python library. The result:

  stat("/usr/lib/python2.0/mod_python", 0xbfffeaec) =
-1 ENOENT (No such file or directory)
  open("/usr/lib/python2.0/mod_python.so", O_RDONLY) =
-1 ENOENT (No such file or directory)
  open("/usr/lib/python2.0/mod_pythonmodule.so",
O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/usr/lib/python2.0/mod_python.py", O_RDONLY) =
-1 ENOENT (No such file or directory)
  open("/usr/lib/python2.0/mod_python.pyc", O_RDONLY)
= -1 ENOENT (No such file or directory)
  stat("/usr/lib/python2.0/plat-linux2/mod_python",
0xbfffeaec) = -1 ENOENT (No such file or directory)
  open("/usr/lib/python2.0/plat-linux2/mod_python.so",
O_RDONLY) = -1 ENOENT (No such file or directory)
 
open("/usr/lib/python2.0/plat-linux2/mod_pythonmodule.so",
O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/usr/lib/python2.0/plat-linux2/mod_python.py",
O_RDONLY) = -1 ENOENT (No such file or directory)
 
open("/usr/lib/python2.0/plat-linux2/mod_python.pyc",
O_RDONLY) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/python2.0/lib-tk/mod_python",
0xbfffeaec) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/python2.0/site-packages/mod_python",
0xbfffeaec) = -1 ENOENT (No such file or directory)
 
open("/usr/lib/python2.0/site-packages/mod_python.so",
O_RDONLY) = -1 ENOENT (No such file or directory)
 
open("/usr/lib/python2.0/site-packages/mod_pythonmodule.so",
O_RDONLY) = -1 ENOENT (No such file or directory)
 
open("/usr/lib/python2.0/site-packages/mod_python.py",
O_RDONLY) = -1 ENOENT (No such file or directory)
 
open("/usr/lib/python2.0/site-packages/mod_python.pyc",
O_RDONLY) = -1 ENOENT (Nosuch file or directory)
  write(2, "make_obcallback(): could not imp"..., 55)
= 55
  write(2, "make_obcallback(): could not cal"..., 40)
= 40
  time(NULL)                              = 996027790
  write(15, "[Wed Jul 25 03:23:10 2001] [erro"...,
115) = 115
  alarm(300)                              = 0
  alarm(0)                                = 300
  alarm(300)                              = 0
  alarm(0)                                = 300
  alarm(300)                              = 0
  alarm(0)                                = 300
  write(4, "HTTP/1.1 500 Internal Server Err"..., 843)
= 843

This is odd because my system python version is 1.5
and I have a special version in a private 
directory which I specified (as above) at compile
time.

grepping apache (incl. mod_python.so) and python
binaries for "/usr/lib" did not reveal anything of
immediate
interest. Recompiling with python 2.1 renders
essentially the same result (substitude "2.1" for
"2.0" in the
trace output).

The problem is obviously something like the PYTHONPATH
not being set properly. 

  -Setting the PythonPath (as was suggested in a prior
exchange) seems ineffective-- strace behaviour was not

   changed (in fact specifying an arbitrary string set
for the PythonPath directive did not appear in trace
output).
  
  -setting the PYTHONPATH variable in the shell before
starting httpd had no effect

  -using the specially compiled python shell to try
"from mod_python import apache" failed when it could
   not find the "_apache" module, leading me to
believe it did find the mod_python module. I did this
   experiment using the same permissions as httpd, and
have tried experimentally running httpd with my own 
   permissions without success.

The mod_python.so file is 2.7MB with python 2.0 and
1.5MB with 2.1, leading me to believe it is being
linked
properly-- I have scrutinized the build process for
errors and not seen anything interesting. Thus I find
myself
among the ranks of unhappy people looking at:

  [Wed Jul 25 04:03:20 2001] [info] Server built: Jul
25 2001 00:55:54
  make_obcallback(): could not import
mod_python.apache.
  make_obcallback(): could not call init.
  [Wed Jul 25 04:03:22 2001] [error] [client
192.168.0.0.2] python_handler: make_ob
  callback returned no obCallBack!

I look forward to being able to move out of
AOLserver-land (filters and threading are coming to
Apache. yay). 
Any clues?

cheers,
jamie



__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



More information about the Mod_python mailing list