[mod_python] ImportError: No module named linecache

Marty Alchin gulopine at gamemusic.org
Mon Jun 25 07:23:51 EDT 2007


On 6/24/07, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
> > As for specifying PATH directly for Apache, I tried the following, and
> > it didn't seem to make a difference, but if mod_python was compiled
> > against the wrong Python, I expect this wouldn't make any difference.
> >
> > # env PATH=/usr/local/lib/python2.4:$PATH /usr/local/apache2/bin/httpd -k start
>
> Use:
>
>   env PATH=/usr/local/bin:$PATH /usr/local/apache2/bin/httpd -k start
>
> You need to add bin directory not lib directory to PATH.

Unfortunately, that seems to have no impact.

> > > Also run the command line python executable for the version you expect
> > > to be able to use and go:
> > >
> > >   import mod_python
> >
> > # sudo -u apache python
> > Python 2.4.3 (#1, May 12 2007, 21:38:42)
> > [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import mod_python
> > >>>
> >
> > That's the preferred user, as well as the preferred version of Python,
> > and it imports just fine. Of course, "from mod_python import apache"
> > fails, but with the expected _apache ImportError, so that seems fine.
>
> What about linecache. Forgot to ask that.
>
> Is it possible that that module (.py or .pyc)  in Python installation
> is not readable to the Apache user.

Since I hadn't been replying to the whole list, you missed my reply to
Jim regarding that:

# sudo -u apache python
Python 2.4.3 (#1, May 12 2007, 21:38:42)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import traceback
>>> import linecache
>>>

Everything imports fine in this case.

> > Might I have to recompile mod_python and specify the intended Python
> > installation?
>
> If you didn't explicitly compile it for the version you want to be
> used then perhaps. Use --with-python option as mentioned before.

I'll give that a shot and report back. Thanks for the help.

> PS, please use reply-all to keep discussion on list.

Whoops, sorry about that! I'm used to lists that put the list's email
in the reply-to, so I didn't even think to check the headers before
replying.

-Gul


More information about the Mod_python mailing list