[mod_python] Question about PythonImport and how to fully qualifymodule names in relation to docroot of Apache2

Graham Dumpleton grahamd at dscpl.com.au
Thu Apr 7 21:08:25 EDT 2005

jarrod roberson wrote ..
> my docroot is /www
> I have sub dirs with __init__.py files in /www/test
> and a python file testapp.py in /www/test
> PythonImport test main_interpreter
> doesnt work
> PythonImport test.testapp main_interpreter
> doesnt work either?
> any ideas

PythonImport must be defined at global scope and as such there
will have been no modifications to sys.path corresponding to any
PythonHandler declarations. Thus, you need to explicitly set the
PythonPath directive to include any locations which should be
searched for your module. If this isn't being done by you now, you
are most likely importing the "test" module that comes with Python
and not your own. It isn't actually wise to use a module name for
your own stuff which is the same as one that comes with Python.

Thus, try setting PythonPath. If you are already, post the snippet
of your Apache configuration where you are setting everything
for mod_python. Also show what error messages you might be
getting in the Apache log file. You might have to shutdown Apache
to ensure that Python import error messages in this case are being
flushed to the log.


More information about the Mod_python mailing list