[mod_python] "could not import mod_python.apache

Trevor Hennion trevor at thennion.demon.co.uk
Wed Sep 7 02:57:55 EDT 2005

The failure of importing the apache module when requested from the 
python interpreter run from the command line is expected - it needs to 
be called by apache. It does show that the mod_python module is found by 
python so that is a good thing.

Have a look at Graham Dumpleton's articles at:
These can help greatly.

Trevor Hennion

Tim Bellefy wrote:
> Thanks for replying.
> I added an alias in:   /root/.cshrc
> alias python /usr/local/bin/python2.4
> This tells every user to use python2.4 instead of old version
> Just to be safe, I added the same alias to the user apache is using running under.
> I tried calling my test.py from the command line again and it still fails.
> Joshua Kifer <joshua at codeputty.com> wrote:
> Apache is running a different install of python than the one you 
> compiled against.
> Make sure apache is running the python at: (that is, make sure it's 
> first in the path of the user running apache):
> /usr/local/bin/python2.4
> (that is, make sure it's first in the path of the user that is 
> running apache)
> On Sep 6, 2005, at 12:24 PM, Tim Bellefy wrote:
>>Hi All,
>>I just installed mod_python so please bear with me...
>>Steps I've done:
>>OS: FreeBSD 4.7
>>Installed Python 2.4.1
>>Installed Apache 2.0.54
>>Installed mod_python 3.1.4
>>./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/ 
>>make install
>>Everything installed fine.
>>However, When I try the simple example found on modpyhon.org, I get 
>>an error.
>>from mod_python import apache
>>def handler(req):
>>req.write("Hello World!")
>>return apache.OK
>>APACHE http.conf
>>Options ExecCGI
>>AllowOverride All
>>AddHandler mod_python .py
>>PythonHandler mptest
>>PythonDebug On
>>[Tue Sep 06 19:09:39 2005] [error] make_obcallback: could not 
>>import mod_python.apache.
>>Traceback (most recent call last):
>>File "test.py", line 2, in ?
>>from mod_python import apache
>>File "/usr/local/lib/python2.4/site-packages/mod_python/ 
>>apache.py", line 28, in ?
>>import _apache
>>ImportError: No module named _apache
>>Any Help????
>>Do You Yahoo!?
>>Tired of spam? Yahoo! Mail has the best spam protection around
>>Mod_python mailing list
>>Mod_python at modpython.org
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> ------------------------------------------------------------------------
> _______________________________________________
> 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