[mod_python] mod_python and module importing

.: smilelover :. smilelover at centrum.cz
Wed May 10 05:04:15 EDT 2006


Hi guys,
I have a simple python web running on mod_python, but I have serious troubles with importing my own modules located in the project directory.

I have index.py and a directory called "lib", which contains a file called MyWebTools.py.
I have added the path to sys.path via:

PythonPath "sys.path+[os.getcwd()+'/lib']"

in .htaccess.

But when I use "import MyWebTools", I get an error message saying no such module exists a and it is the same when I place MyWebTools.py directly into the project dir.

The most weird I experienced is, that sometimes it works, somwtimes not. And sometimes it works partialy - the module is imported, but Python says that instances of a class contained in MyWebTools do not have certain attributes (even though they DO have them and when I declare the class in index.py, everything works fine).
But most of the time it says the module is not there.

So how can I safely import a module?



More information about the Mod_python mailing list