I want to run python file in browser.
I have installed apache. and configured httd.conf
file.
I have created test.py
file.
I then tried running test.py
with my browser by typing htt://localhost/test.py
. When I do this, I get the following error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
In my error log
[Thu Jul 07 18:39:55 2011] [error] [client 127.0.0.1] (OS 2)The system cannot find the file specified. : couldn't create child process: 720002: test.py
[Thu Jul 07 18:39:55 2011] [error] [client 127.0.0.1] (OS 2)The system cannot find the file specified. : couldn't spawn child process: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/test.py
What could be the problem here?
It may also happen if your shebang is not correct (for example, an Unix one like #!/usr/bin/env python
). If this is the case, change it to the correct path to your Python executable (for example: #!C:\Python26\python.exe
) or look at this answer:
How do I ignore the Perl shebang on Windows with Apache 2?
Options +ExecCgi under htdocs, ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"
It's what I have and it works
If it's a CGI program, make sure it conforms to the CGI specification (i.e. it outputs a header line with the MIME type and a blank line before trying to write anything else)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With