[mod_python] PythonPath without application path

Graham Dumpleton grahamd at dscpl.com.au
Fri Apr 28 08:58:29 EDT 2006

Setting PythonPath stops mod_python from looking in the directory
the directive is defined for. Thus, when you set PythonPath, also
add into it the directory the handler is in.

The new importer being developed for mod_python 3.3 will solve
this problem and many others. You may want to read:


so you are aware of various other issues that exist as well.


On 28/04/2006, at 9:32 PM, David Siroky (net) wrote:

> Hi!
> I have an application which uses another library located in a special
> directory and I used
> PythonPath "['/mujbin/python_modules'] + sys.path"
> to access the library for imports. Everything went well but suddenly it
> stopped working:
> Mod_python error: "PythonHandler apphandler"
> Traceback (most recent call last):
>   File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 
> 287, in HandlerDispatch
>     log=debug)
>   File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 
> 454, in import_module
>     f, p, d = imp.find_module(parts[i], path)
> ImportError: No module named apphandler
> where apphandler.py is the entry point for my application. My .htaccess
> (in the same directory as apphandler.py):
> SetHandler mod_python
> PythonDebug On
> PythonHandler apphandler
> PythonAutoReload On
> PythonPath "['/mujbin/python_modules'] + sys.path"
> When I remove the PythonPath the apphandler is imported (but I need the
> library). I printed the sys.path and now it contains the
> '/mujbin/python_modules' but no more the directory with my app.
> How is that possible? I guess it some stupid thing but I don't remember
> changing anything that can possibly alter the behavior. I'm lost.
> Thank you.
> David
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list