[mod_python] importing from package under mod_python.publisher

Sergiy Kuzmenko s.kuzmenko at gmail.com
Sun Apr 13 21:54:36 EDT 2008

Hi everybody,

Question about importing from package under mod_python.publisher.

Consider the following directory structure:


Let's say we have the following in test.py:

 import boo
 import foo.bar

When running test.py from command line this works fine. However, under
mod_python only "import boo" works and importing from a subdirectory
via "import foo.bar" produces ImportError: No module named foo.

This seems to be a deviation form the standard python's behaviour.

What is even more confusing that mod_python manual
states the following when describing the PythonHandler directive: "If
not already done, prepend the directory in which the PythonHandler
directive was found to sys.path".

When inspecting sys.path from a publisher defined like this:

<Directory /path/to/the/webroot/py>
 AddHandler mod_python .py
 PythonHandler publisher
 PythonDebug On

/path/to/the/webroot/py is actually not the system path!


More information about the Mod_python mailing list