[mod_python] 3.3.1: ImportError: No module named python

Gerry Reno greno at verizon.net
Sat Dec 4 14:22:53 EST 2010


Hi,
   I've been trying to get mod_python running on my xampp apache 
installation.  I seem to be close but keep getting this error in apache log:

    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46] URI:
    '/mod_python/test.py'
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46] Location: None
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46] Directory:
    '/opt/lampp/htdocs/mod_python/'
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46] Filename:
    '/opt/lampp/htdocs/mod_python/test.py'
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46] PathInfo: ''
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46] Traceback
    (most recent call last):
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46]   File
    "/opt/lampp/lib/python2.7/site-packages/mod_python/importer.py",
    line 1537, in HandlerDispatch\n    default=default_handler, arg=req,
    silent=hlist.silent)
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46]   File
    "/opt/lampp/lib/python2.7/site-packages/mod_python/importer.py",
    line 1202, in _process_target\n    module =
    import_module(module_name, path=path)
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46]   File
    "/opt/lampp/lib/python2.7/site-packages/mod_python/importer.py",
    line 304, in import_module\n    return __import__(module_name, {},
    {}, ['*'])
    [Sat Dec 04 14:01:16 2010] [error] [client 192.168.1.46]
    ImportError: No module named python


I've rerun the configure script several times changing a few options but 
it doesn't help.  Here is the latest configure line:

    ./configure --prefix=/opt/lampp/ --with-apxs=/opt/lampp/bin/apxs
    --with-python=/opt/lampp/bin/python2.7
    --with-mutex-dir=/opt/lampp/var/run/python --bindir=/opt/lampp/bin
    --sbindir=/opt/lampp/sbin --sysconfdir=/opt/lampp/etc 
    --localstatedir=/opt/lampp/var --libdir=/opt/lampp/lib
    --includedir=/opt/lampp/include


make and make install run without problem

My apache configs:

    sudo echo "Include etc/extra/httpd-python.conf" >>
    /opt/lampp/etc/httpd.conf
    sudo echo "LoadModule python_module modules/mod_python.so

    <Directory \"/opt/lampp/htdocs/mod_python\">
    PythonPath \"['/opt/lampp/htdocs/mod_python']+sys.path\"
    AddHandler mod_python .py
    PythonHandler python
    PythonDebug On
    Order allow,deny
    Allow from all
    </Directory>
    " > /opt/lampp/etc/extra/httpd-python.conf

    sudo mkdir /opt/lampp/htdocs/mod_python
    sudo echo "import sys
    from mod_python import apache
    def handler(req):
        req.content_type = \"text/html\"
        req.write(\"<html><head></head><body>\")
        req.write(\"<h1>Python is running with mod_python...</h1>\")
        req.write(\"<p>Python prefix: </p>\" % sys.prefix)
        req.write(\"<p>Python path: </p>\" % sys.path)
        req.write(\"<p>Python version: </p>\" % sys.version)
        return apache.OK" > /opt/lampp/htdocs/mod_python/test.py


When I start apache the log shows:

    [Sat Dec 04 14:01:02 2010] [notice] Digest: generating secret for
    digest authentication ...
    [Sat Dec 04 14:01:02 2010] [notice] Digest: done
    [Sat Dec 04 14:01:03 2010] [warn] RSA server certificate is a CA
    certificate (BasicConstraints: CA == TRUE !?)
    [Sat Dec 04 14:01:03 2010] [warn] RSA server certificate CommonName
    (CN) `localhost' does NOT match server name!?
    [Sat Dec 04 14:01:03 2010] [notice] mod_python: Creating 8 session
    mutexes based on 256 max processes and 0 max threads.
    [Sat Dec 04 14:01:03 2010] [notice] mod_python: using
    mutex_directory /opt/lampp/var/run/python
    [Sat Dec 04 14:01:03 2010] [notice] Apache/2.2.6 (Unix) DAV/2
    mod_ssl/2.2.6 OpenSSL/0.9.8e mod_python/3.3.1 Python/2.7.1
    mod_wsgi/3.3 PHP/5.2.4 mod_apreq2-20051231/2.5.7 mod_perl/2.0.2
    Perl/v5.8.7 configured -- resuming normal operations



Can you see anything wrong in my configurations?


-Gerry








More information about the Mod_python mailing list