[mod_python] PYTHONPATH and mod_python

Graham Dumpleton grahamd at dscpl.com.au
Wed Dec 20 16:31:45 EST 2006


Soenke Ruempler - NorthClick  wrote ..
> Hi,
> 
> We're using a managed server and have our own apache + mod_python running.
> All went fine until the server was rebooted by the provider.
> 
> Now I get:
> 
> [Wed Dec 20 11:22:07 2006] [notice] SIGHUP received.  Attempting to restart
> [Wed Dec 20 11:22:07 2006] [notice] mod_python: Creating 8 session mutexes
> based on 150 max processes and 0 max threads.
> [Wed Dec 20 11:22:07 2006] [notice] mod_python: using mutex_directory
> /www/94219_27474/local/tmp
> [Wed Dec 20 11:22:07 2006] [notice] Apache/2.0.55 (Unix) DAV/2 SVN/1.3.2
> mod_python/3.2.10 Python/2.5 configured -- resuming normal operations
> 
> 
> [Doing the first HTTP request here]
> 
> [Wed Dec 20 11:22:13 2006] [error] make_obcallback: could not import
> mod_python.apache.\n
> ImportError: No module named mod_python.apache
> [Wed Dec 20 11:22:13 2006] [error] make_obcallback: Python path being used
> "['/usr/lib/python25.zip', '/usr/lib/python2.5',
> '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk',
> '/usr/lib/python2.5/lib-dynload', '/usr/lib/python2.5/site-packages',
> '/usr/lib/python2.5/site-packages/PIL']".
> [Wed Dec 20 11:22:13 2006] [error] python_handler: no interpreter callback
> found.
> [Wed Dec 20 11:22:13 2006] [error] [client xxx] python_handler: Can't
> get/create interpreter.
> 
> [500 Interal Server Error]
> 
> I guess the problem is the PYTHONPATH is being ignored by apache+mod_python.
> Mod_python is installed into some local dir and the PYTHONPATH is set:
> 
> # env | grep PY
> PYTHONPATH=/www/94219_27474/local/lib/python2.5/site-packages/:/www/94219_27
> 474/local/lib/svn-python:
> 
> The intepreter gets the path from commandline:
> 
> # python2.5
> Python 2.5 (r25:51908, Sep 22 2006, 18:03:12)
> [GCC 3.3.5  (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> sys.path
> ['', '/www/94219_27474/local/lib/python2.5/site-packages',
> '/www/94219_27474/local/lib/svn-python', '/kunden/94219_27474',
> '/usr/lib/python25.zip', '/usr/lib/python2.5',
> '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk',
> '/usr/lib/python2.5/lib-dynload', '/usr/lib/python2.5/site-packages',
> '/usr/lib/python2.5/site-packages/PIL']
> >>> import mod_python.apache
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "usr/lib/python2.5/site-packages/mod_python/apache.py", line 28,
> in
> <module>
> ImportError: No module named _apache
> 
> I guess this looks good (as I've seen it in some mail archives).
> 
> But somehow the PYTHONPATH is not used while mod_python initialization?!
> 
> Any help would be appreciated. :)

Apache is normally run as a separate user. The PYTHONPATH variable definition
has to be set in the environment of that user. If the way Apache is started at
reboot means it doesn't actually inherit the environment of that user, then it
would have to be set somehow in the Apache startup scripts.

At the moment I am assuming that you are only setting PYTHONPATH in your own
account and it has perhaps worked prior to the reboot as the means you were
using to restart Apache was inheriting it from your own environment.

Graham


More information about the Mod_python mailing list