David Fraser
davidf at sjsoft.com
Thu Aug 14 09:25:36 EST 2003
William J. Fellows wrote: >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 > > > From this error, it means you are putting mptest.py in your cgi-bin directory. If it is in there it is probably being run as an external Python script, which is not what you want as you won't have access to the mod_python internals. Try moving it to a standard directory, then in an .htaccess or <Directory> section for that directory, make sure you have AddHandler python-program .py PythonHandler mptest.py PythonDebug On (that's the correct combination out of what you quoted below). Then feed back if that doesn't work. >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 > > It looks from your log above like the path is fine, as you are importing mod_python.apache OK. You will only be able to import _apache if you are really running inside mod_python. If you want to test the path, comment out the import of apache (you can return 200 instead of apache.OK) and import sys ; in the handler do req.write("Path: %r\n" % sys.path) and you will get the actual value printed out. Hope that helps David
|