在浏览器中运行.py文件

Roy*_*nto 7 python apache cgi

我想在浏览器中运行python文件.我已经安装了apache.和配置httd.conf文件.我创建了test.py文件.然后我尝试test.py通过键入运行我的浏览器htt://localhost/test.py.当我这样做时,我收到以下错误:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, lohith.pinto@primefocusworld.com 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.
Run Code Online (Sandbox Code Playgroud)

在我的错误日志中

[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
Run Code Online (Sandbox Code Playgroud)

这可能是什么问题?

ngọ*_*oss 11

如果你的shebang不正确(例如,像Unix一样#!/usr/bin/env python),也可能发生这种情况.如果是这种情况,请将其更改为Python可执行文件的正确路径(例如:):#!C:\Python26\python.exe或者查看以下答案: 如何在Apache 2上忽略Windows上的Perl shebang?


Chr*_*egg 0

如果您尚未执行此操作,则需要将适当的权限设置test.py为 755。