我正在使用python 2.7.13
起初浏览器显示的是原始代码。
我所做的:
AddHandler cgi-script .cgi .pl .asp .py
在我的所有脚本的顶部,我添加了以下内容:
#!j:/Installeds/Python/python
print "Content-type: text/html\n\n"
现在它给了我Internal Server Error (500)
我不知道还有什么可以尝试。。。第一次使用python。
Obs:我认为这可能有帮助
[cgi:error] [pid 6364:tid 1620] (9)Bad file descriptor: [client ::1:51083] AH01222: don't know how to spawn child process: C:/Files and Installs/Xampp/htdocs/Test/main.py
AH02102: C:/Files and Installs/Xampp/htdocs/Test/main.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
在xampp for windows中运行Python:
第一步:[下载Python]
从www.python.org下载并安装最新版本的python单击任何版本的windows安装程序 [例如python-3.6.2]
步骤2:[安装Python] 在硬盘的任何目录中安装 [例如D:\ python-3.6.2]
步骤3:[配置Python] XAMPP GUI可以快速访问httpd.conf文件,如下所示:
否则打开安装xammp的目录 转到apache>;>;conf
e.g.) D:\xampp\apache\conf\httpd.conf
。 您将看到一个名为httpd.conf
的文件。在任何文本编辑器中打开它,并将以下代码放在该文件的末尾:步骤4:[可选]
在同一个文件中搜索
<IfModule dir_module>
。 当你找到它的时候,把index.py
放在最后 会像这样步骤5:[重新启动apache/xampp]
只需编辑,现在从xampp控制面板重新启动apache
步骤6:[从xammp运行Python]
现在在xammp htdoc目录[ex.D:\ xampp\htdocs\PythonProject]上打开文本编辑器&test python。 但是在脚本的开头,您需要指定安装python的路径。在我的例子中是D:/python-3.6.2/python.exe,在您的例子中可能会有所不同,这取决于您安装python的版本以及硬盘python代码的目录。
或者
将文件另存为htdocs&;open
http://localhost/PythonProject\test.py
中的test.py。如果一切顺利,您将看到文本“Hello Python Web Browser!!太酷了!!”我在运行ubuntu 16.04,所以我的答案可能有点不同。我正在使用google chrome浏览器和python 3文件test.py in/opt/lampp/htdocs/PythonProject:
我在/opt/lampp/etc/httpd.conf中编辑了我的httpd.conf文件,但我没有添加
在文件的末尾,我将.py添加到现有行的末尾
最后,我通过
chmod +x /opt/lampp/htdocs/PythonProject/test.py
使文件可执行,然后我只需在浏览器中运行它:输出:
错误的文件描述符意味着一个文件已损坏,并且它说它无法运行脚本,因此您可能错误地设置了python。
相关问题 更多 >
编程相关推荐