[mod_python] Troubles with including local modules

Jim Gallacher jpg at jgassociates.ca
Tue May 30 09:02:53 EDT 2006


Pavel Roitberg wrote:
> Hi,
> 
> I'm trying to dig into python using mod_python, but I already fail with
> this easy thing.
> I can include modules located in /usr/lib without problems, but when I
> try to include a local module I'm getting the following error:
> 
> """
> Mod_python error: "PythonHandler index"
> 
> 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
> 457, in import_module
>     module = imp.load_module(mname, f, p, d)
> 
>   File "/home/pavel/data/webwork/python/index.py", line 3, in ?
>     from module import article
> 
> ImportError: cannot import name article
> """
> 
> It only works after python generates the according pyc files. (when I
> import them manually using the interpreter)
> 
> Apache.import_module() does not work at all; neither error, nor module
> in local namespace.
> 
> The environment is:
> mod_python 3.1.4
> apache 2.0.55-4ubuntu2
> python 2.4.2-0ubuntu3
> Ubuntu 6.06
> 

It's not clear to my why it works for pyc files, but not py files. 
Perhaps you could include your mod_python apache configuration 
(AddHandler, etc), and a code snippet.

Jim




More information about the Mod_python mailing list