[Tutor] Python isn't working with Apache (Windows)

Christopher McGrath mcgrath_ch at hotmail.com
Mon Jul 31 01:31:40 EDT 2017


I am trying to run a simple python web script in a browser with apache. I have apache installed and running perfectly. I installed Ruby and Perl using instructions from here and worked perfect. http://editrocket.com/articles/python_apache_windows.html

I did have to change my “shebang lines” for PERL and RUBY like these:
#!Q:\LifeForce\perl\perl\bin\perl.exe
#!Q:\LifeForce\Ruby24-x64\bin\ruby.exe
As you can see, I didn’t install them on C: drive. They worked.

I had Python 3.6 installed before and tried to test with these
#!Q:\LifeForce\Python36-32\Scripts\pip3.exe
#!Q:\LifeForce\Python36-32\Scripts\pip.exe
#!Q:\LifeForce\Python36-32\Scripts\pip2.6.exe
All the pip files in the Script directory.
I also tried with #!Q:\LifeForce\Python36-32\python.exe. This one works worked from Window Command, but didn’t work from web browser like PERL and RUBY.
I tried downgrading to Python 2.7 and installed directly at C: drive and tested with
#!C:\Python27\python.exe
#!C:\Python27\Scripts\pip2.7.exe
#!C:\Python27\Scripts\pip2.exe
#!C:\Python27\Scripts\pip.exe
Nothing worked. I don’t have any idea anymore. Please help!
This is the simple code:
print ("Content-type: text/html")
print (" ")
print ("<html><head>")
print ("")
print ("</head><body>")
print ("Hello Python.")
print ("</body></html>")

I am trying to run directly from Apache htdoc dir. Not from cgi dir. I think something is wrong with the shebang line.
This is the error output in the web browser:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at postmaster at localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
This is what is shown in Apache’s error log:
[Mon Jul 31 01:06:54.266478 2017] [cgi:error] [pid 5156:tid 1688] [client 98.5.128.152:51723] malformed header from script 'test.py': Bad header:
[Mon Jul 31 01:06:54.270479 2017] [authz_core:error] [pid 5156:tid 1688] [client 98.5.128.152:51723] AH01630: client denied by server configuration: C:/Apache24








Christopher McGrath

[http://aawisdom.com/Top_of_main_files/BizCard-Front-hotmailSignature.jpg]
[http://aawisdom.com/Top_of_main_files/image001.gif]
www.aawisdom.com<http://www.aawisdom.com> (716) 240-7786


More information about the Tutor mailing list