[mod_python] Python Path

Alan Kennedy modpython at xhaus.com
Wed Jan 16 20:09:17 EST 2002


Rob,

I'm not sure if this will solve your problem, but have you tried placing an
__init__.py in the /var/python directory. With content like this

__all__ = ['browse']

To setup the "browse" package.

Just a suggestion,

Alan.

Robert Sherwood wrote:

> Greetings all:
>
> Someone is going to kick me, but I know I'm overlooking something
> obvious and I was hoping one of you could spot it.
>
> I am trying to have my main PythonHandler import a module that is below
> it in the directory tree. Here is the basic information:
>
> =========================================================
>
> 0. mod_python 2.7.6 running on debian unstable, using python-2.1.1
>
> 1. Scripts located in and below "/var/python"
>
> 2. mod_python listening on an apache VirtualHost
>
> 3. Config file as follows:
>   Listen 8080
>   <VirtualHost beelzebub:8080>
>     DocumentRoot /var/python
>     PythonPath "['/var/python/'] + sys.path"
>     PythonDebug On
>     PythonAutoReload On
>     SetHandler python-program
>     PythonTransHandler trans
>     PythonHandler main
>   </VirtualHost>
>
> 4. Python handler main failing at this directive:
>
>   File "/var/python/main.py", line 3, in ?
>      import browse.listArtists
>
>   ImportError: No module named browse.listArtists
>
> 5. ls -F /var/python
>
> admin/   data/    main.pyc  objects/     playlists/    template/  trans.pyc
> browse/  main.py  mod_mp3/  parseRDF.py  preferences/  trans.py
>
> 6. ls -F /var/python/browse
>
> __init__.py  listArtistAlbumSongs.py  listArtistAlbums.py
> listArtists.py
>
> ========================================================
>
> I can't figure it out. It is as if the PythonPath directive were not
> being inherited by the interpreter running main.py. Is this a bug, or am
> I stupid?
>
> Or both :)
>
> Thanks in advance for any help anyone can offer.
>
> Robert Sherwood
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python




More information about the Mod_python mailing list