[mod_python] Big Issue w/ sys.path

jalil jalil at securia.com
Sun Feb 8 16:23:10 EST 2004

Thanks for the info. I remember reading some notes on PSP where there 
was a pylib dir and the sys.path was set to include pylib. I just 
followed the example. My fault!

I made changes and I now don't set the sys.path anymore. I turned my 
pylib dir into a package and then imported modules explicitly using the 
apache.import_module("pylib.<module>") in my psp files. However, when I 
run both apps, the base dir of both apps appears in the sys.path (which 
now makes sense) in a random order, so, to prevent the problem, I still 
have to rename my pylib dir to pylibs in test dir and modify the path in 
the import_apache calls when I move the files for testing.

It is not a clean solution but works for now. If there is a better way 
to do this  (without using virtual hosts or a sub-interpreter), please 
let me know.



Gregory (Grisha) Trubetskoy wrote:

>On Sun, 8 Feb 2004, jalil wrote:
>>I think Apache starts mod_python in one process and shares it across
>>apps and when I set sys.path in one app it is visible to the other app.
>This is the way it should work. sys.path is global to the sub-intepreter,
>so if both apps are running in the same sub-interpreter, then they share
>sys.path (as well as lots of other things).
>There are two things you can do - first rethink your app so that you don't
>have to change sys.path, the second way is to ensure that the apps are
>running in seprate sub-interpreters.
>The manual has more info on this:

More information about the Mod_python mailing list