[mod_python] YAQA mod_python and the missing _apache module

William J. Fellows donegal at myrealbox.com
Thu Aug 14 00:39:43 EST 2003


I'm sorry to trouble the list but I have not been able to get it
mod_python to work.  My setup is Python 2.2.2, Apache 2.0.47,
mod_python 3.0.3  Python root directory is e:\Python22  Apache's root
is E:\Program Files\Apache Group\Apache2  Windows 2k Professional

I have a sample python script sitting out in cgi-bin and it works just
fine.  The mptest file though, horks everytime.  Feel free to beat on
my server. 
http://65.26.28.214/cgi-bin/sample.py
http://65.26.28.214/cgi-bin/mptest.py


The error message is:
Premature end of script headers: mptest.py
Traceback (most recent call last):
  File "E:\Program Files\Apache Group\Apache2\cgi-bin\mptest.py", line 1, in ?
    from mod_python import apache
  File "E:\Python22\Lib\site-packages\mod_python\apache.py", line 67, in ?
    import _apache
ImportError: No module named _apache


Been here,
http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.001.htp
and I've been there
http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.002.htp

I believe I understand what that says and everything I could find about
it from the archived email messages but unless Apache is invoking the
python enviroment outside of apache, I have no clue what's going
wrong.  And if it is doing it outside, I have no idea how it got that
way.

Saw both pythonhome and pythonpath referenced so I've touched both of
them.

PYTHONHOME=e:\python22
PYTHONPATH=e:\python22;e:\python22\lib;E:\Python22\Lib\site-packages\mod_python;E:\Python22\Lib\site-packages

I'm at my wits end.  I know I can get Python running under IIS but as
I don't feel like patching daily, I thought I'd give Apache a whirl.
I've dutifully scoured the archives and applied what I saw there but
no go so anyone with some insight to offer would be worshiped from
afar.

/bill

p.s.

The link for full archives does not work.
http://www.modpython.org/pipermail/mod_python.mbox/mod_python.mbox
Fortunately, wget -R -a.gz worked just fine.




The relevant parts of my conf file look like

=-=-=-=-=-=-=-=-BEGIN httpd.conf=-=-====-=-=-=-=-=-=--=-
LoadModule python_module modules/mod_python.so
ScriptInterpreterSource Registry

<Directory "E:/Program Files/Apache Group/Apache2/htdocs">
    AddHandler python-program .py
#   I tried combinations of the next two lines but to no avail
#    AddHandler cgi-script .py
#    PythonHandler mptest

    PythonHandler mod_python.publisher
    PythonDebug On

    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

</Directory>
=-=-=-=-=-=-=-=-END httpd.conf=-=-====-=-=-=-=-=-=--=-


=-=-=-=-=-=-=-=-BEGIN sample.py=-=-====-=-=-=-=-=-=--=-
print "Content-type: text/html"
print
print "<pre>"
import os, sys
print "<strong>Python %s</strong>" % sys.version
for (x,y) in os.environ.items():
   print "%s\t%s" % (x, y)

print "\nsys.path"
for p in sys.path:
   print p
print "</pre>"

=-=-=-=-=-=-=-=-END sample.py=-=-====-=-=-=-=-=-=--=-


=-=-=-=-=-=-=-=-BEGIN mptest.py=-=-====-=-=-=-=-=-=--=-
from mod_python import apache

def handler(req):
    req.write("Hello World!")
    return apache.OK

=-=-=-=-=-=-=-=-END mptest.py=-=-====-=-=-=-=-=-=--=-



More information about the Mod_python mailing list