[mod_python] ImportError: No module named mod_python.apache

Graham Dumpleton graham.dumpleton at gmail.com
Wed Aug 1 22:39:13 EDT 2007


Unfortunately the Apache/Python errors don't get ordered correctly as
to get Python messages to display needs an explicit flush. This only
get done later.

Anyway, the reason 'site-packages' wouldn't appear the first time is
that that directory is only added when 'site' is imported. You should
not be adding 'site-packages' explicitly to PYTHONPATH.

However, you are getting:

  'import site' failed; traceback:
  ImportError: No module named site

So 'site' module is failing to import.

Although, earlier it shows:

  # /usr/local/lib/python2.5/site.pyc matches /usr/local/lib/python2.5/site.py
  import site # precompiled from /usr/local/lib/python2.5/site.pyc

That it identifies a site.pyc suggests it does exist. You perhaps
should ensure that it and all other Python installed files are
readable to others. This is necessary as Apache would generally run as
a different user to you.

Also, is /usr/local/bin/python the version of Python executable that
would be found first in the PATH of the user that Apache is run as? Do
you have any other versions of Python 2.5 installed anywhere?

Does it make a difference if you set:

  PYTHONEXECUTABLE=/usr/local/bin/python

in environment of user that Apache is started as?

Graham

On 02/08/07, Marty Alchin <gulopine at gamemusic.org> wrote:
> I've been staring at computer screens for too long today, so I can't
> make heads or tails of this at the moment.
>
> -Gul
>
> [Wed Aug 01 20:45:21 2007] [error] make_obcallback: could not import
> mod_python.apache.\n
> # installing zipimport hook
> import zipimport # builtin
> # installed zipimport hook
> # /usr/local/lib/python2.5/site.pyc matches /usr/local/lib/python2.5/site.py
> import site # precompiled from /usr/local/lib/python2.5/site.pyc
> # /usr/local/lib/python2.5/os.pyc matches /usr/local/lib/python2.5/os.py
> import os # precompiled from /usr/local/lib/python2.5/os.pyc
> import posix # builtin
> # /usr/local/lib/python2.5/posixpath.pyc matches
> /usr/local/lib/python2.5/posixpath.py
> import posixpath # precompiled from /usr/local/lib/python2.5/posixpath.pyc
> # /usr/local/lib/python2.5/stat.pyc matches /usr/local/lib/python2.5/stat.py
> import stat # precompiled from /usr/local/lib/python2.5/stat.pyc
> # /usr/local/lib/python2.5/UserDict.pyc matches
> /usr/local/lib/python2.5/UserDict.py
> import UserDict # precompiled from /usr/local/lib/python2.5/UserDict.pyc
> # /usr/local/lib/python2.5/copy_reg.pyc matches
> /usr/local/lib/python2.5/copy_reg.py
> import copy_reg # precompiled from /usr/local/lib/python2.5/copy_reg.pyc
> # /usr/local/lib/python2.5/types.pyc matches /usr/local/lib/python2.5/types.py
> import types # precompiled from /usr/local/lib/python2.5/types.pyc
> import _types # builtin
> # /usr/local/lib/python2.5/warnings.pyc matches
> /usr/local/lib/python2.5/warnings.py
> import warnings # precompiled from /usr/local/lib/python2.5/warnings.pyc
> # /usr/local/lib/python2.5/linecache.pyc matches
> /usr/local/lib/python2.5/linecache.py
> import linecache # precompiled from /usr/local/lib/python2.5/linecache.pyc
> import encodings # directory /usr/local/lib/python2.5/encodings
> # /usr/local/lib/python2.5/encodings/__init__.pyc matches
> /usr/local/lib/python2.5/encodings/__init__.py
> import encodings # precompiled from
> /usr/local/lib/python2.5/encodings/__init__.pyc
> # /usr/local/lib/python2.5/codecs.pyc matches /usr/local/lib/python2.5/codecs.py
> import codecs # precompiled from /usr/local/lib/python2.5/codecs.pyc
> import _codecs # builtin
> # /usr/local/lib/python2.5/encodings/aliases.pyc matches
> /usr/local/lib/python2.5/encodings/aliases.py
> import encodings.aliases # precompiled from
> /usr/local/lib/python2.5/encodings/aliases.pyc
> # /usr/local/lib/python2.5/encodings/utf_8.pyc matches
> /usr/local/lib/python2.5/encodings/utf_8.py
> import encodings.utf_8 # precompiled from
> /usr/local/lib/python2.5/encodings/utf_8.pyc
> import __builtin__ # previously loaded (__builtin__)
> import sys # previously loaded (sys)
> # installing zipimport hook
> import zipimport # previously loaded (zipimport)
> # installed zipimport hook
> 'import site' failed; traceback:
> ImportError: No module named site
> ImportError: No module named mod_python.apache
> [Wed Aug 01 20:45:21 2007] [error] make_obcallback: Python path being
> used "['/usr/local/lib/python2.5/site-packages',
> '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5/',
> '/usr/local/lib/python2.5/plat-linux2',
> '/usr/local/lib/python2.5/lib-tk',
> '/usr/local/lib/python2.5/lib-dynload']".
> [Wed Aug 01 20:45:21 2007] [error] get_interpreter: no interpreter
> callback found.
> [Wed Aug 01 20:45:21 2007] [error] [client 24.11.212.122]
> python_handler: Can't get/create interpreter.
>
> On 8/1/07, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
> > Run it again, setting:
> >
> >   PYTHONVERBOSE=1
> >
> > in the environment.
> >
> > The error is while site file is being imported, ie., before
> > mod_python.apache is imported.
> >
> > Post back result to the mailing list.
> >
> > Graham
> >
> > On 02/08/07, Marty Alchin <gulopine at gamemusic.org> wrote:
> > > I was having problems with mod_python recently, so I decided to
> > > upgrade to Python 2.5 (which I had wanted to do anyway), reinstall
> > > mod_python and try again. I'm getting the following error, however,
> > > and I can't sort out why.
> > >
> > > [Wed Aug 01 18:20:53 2007] [error] make_obcallback: could not import
> > > mod_python.apache.\n
> > > 'import site' failed; use -v for traceback
> > > ImportError: No module named mod_python.apache
> > > [Wed Aug 01 18:20:53 2007] [error] make_obcallback: Python path being
> > > used "['/usr/local/lib/python2.5/site-packages',
> > > '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5/',
> > > '/usr/local/lib/python2.5/plat-linux2',
> > > '/usr/local/lib/python2.5/lib-tk',
> > > '/usr/local/lib/python2.5/lib-dynload']".
> > > [Wed Aug 01 18:20:53 2007] [error] get_interpreter: no interpreter
> > > callback found.
> > > [Wed Aug 01 18:20:53 2007] [error] [client 24.11.212.122]
> > > python_handler: Can't get/create interpreter.
> > >
> > > Initially, it seemed to make sense, since Python's site-packages
> > > wasn't listed in the path that was being used. However, when I run it
> > > with PYTHONPATH=/usr/local/lib/python2.5/site-packages, it still runs
> > > into the same error, and as you can see, site-packages is now
> > > included. I haven't found anything else in the logs that sheds any
> > > light on the subject.
> > >
> > > Is there something I can do to get more information about what's going wrong?
> > >
> > > -Gul
> > > _______________________________________________
> > > 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