[mod_python] wierd python path problem

David Geller dg at sponsera.com
Mon Oct 4 01:32:22 EDT 2004


Hi All -

A very strange problem appeared today.

[ Config: RHat 9, Python2.2.3, mod_python 3.0.4 ]

I've been running our application on a server for *months*, and it has 
been running fine.

All of a sudden, it stopped working. I finally found the problem: the 
sys.path was wrong!

Background:

Installed on the machine was an original version of python under 
/usr/lib/python2.2.

Months ago, when I installed our app, I had built from source a more 
up-to-date version of python under /usr/local/lib/python2.2, along with 
a mod_python built against this new python. All of my custom packages 
were put under this /usr/local version, and everything has been working 
like a champ.

Until just recently. After several apache restarts, when I traced the 
path internally, I found the mod_python trying to find things in the 
original "/usr/lib/python2.2", *not* the /usr/local version. When I 
renamed the /usr/lib/python2.2 version to something else (and restarted 
apache), mod_python started again looking at the /usr/local version, and 
now everything is working again.

Questions:

1. How does mod_python (or Python, for that matter) get the "initial", 
compiled-in version of the path to search? If there is no PYTHONPATH 
variable, etc., will it *always* first looked at "/usr/lib" *first*, no 
matter what? *Then* try /usr/local/lib if not one there? I had always 
thought that the defaults where internalized from which  target 
directory Python was compiled to. (i.e., if I was going to install in 
/usr/local, via "configure", the default would be /usr/local/lib/pythonXX).

2. Why/How/What would cause the behavior to change like this so 
suddenly? I have looked at all the obvious things (like somone 
installing a new python 2. under /user/lib, or other config changes), 
but nothing seems obvious.

Thanks for your help!

David Geller


More information about the Mod_python mailing list