简体   繁体   English

运行 Python 程序时出现内部服务器错误

[英]Internal Server Error while running Python Program

I am running XAMPP on windows, and trying to run following python code and it is giving 500 Internal Server Error, when I checked error log it says:AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name, [cgi:error] [pid 17416:tid 1836] (OS 5)Access is denied. I am running XAMPP on windows, and trying to run following python code and it is giving 500 Internal Server Error, when I checked error log it says:AH01909: www.example.com:443:0 server certificate does NOT include an ID which匹配服务器名称,[cgi:error] [pid 17416:tid 1836] (OS 5)访问被拒绝。 : [client::1:1031] AH01223: couldn't spawn child process: C:/xampp/htdocs/test.py :[client::1:1031] AH01223:无法生成子进程:C:/xampp/htdocs/test.py

My code: #:C:/Users/Sravani/AppData/Local/Programs/Python/Python38-32 print ("Content-type:text/html\n") print ("") print ("") print ("First CGI Program") print ("") print ("") print ("我的代码:#:C:/Users/Sravani/AppData/Local/Programs/Python/Python38-32 print ("Content-type:text/html\n") print ("") print ("") print ("第一个 CGI 程序") print ("") print ("") print ("

Hello你好

") print ("") print ("") ") 打印 ("") 打印 ("")

can anyone help me in this regard谁能在这方面帮助我

You should probably check if it's the wrong location您可能应该检查它是否是错误的位置

#:C:/Users/Sravani/AppData/Local/Programs/Python/Python38-32 #:C:/Users/Sravani/AppData/Local/Programs/Python/Python38-32

use install.bat i posted here: https://stackoverflow.com/a/71735909/5781320使用我在此处发布的 install.bat: https://stackoverflow.com/a/71735909/5781320

in windows 10 x64+ apache + php 8.1 +... and python associated correctly i have in my htdocs a folder test where i have 2 files: in windows 10 x64+ apache + php 8.1 +... and python associated correctly i have in my htdocs a folder test where i have 2 files:

index.php index.php

<?php

// Highest priority
proc_nice(-20);

//echo shell_exec('index.rb');
//system('index.rb');

echo shell_exec('index.py');
//system('index.py');


?>

and index.py :index.py

print('Python:Hello, World!')打印('Python:你好,世界!')

by calling in browser http://localhost/test/ i got running the python script without calling it cgi (.#...)通过在浏览器中调用 http://localhost/test/ 我运行了 python 脚本而不调用它 cgi (.#...)

i let in place the comments you read..我让您阅读的评论到位。

//echo shell_exec('index.rb');
//system('index.rb');

cause i have even ruby and the index.rb and they running both.因为我什至有 ruby 和 index.rb 并且它们都运行。 (i am not python user and neither ruby but i usually for a while i try both of them -even golang to see what's new..) (我不是 python 用户,也不是 ruby 但我通常会尝试他们两个 - 甚至 golang 看看有什么新的..)

the index.rb索引.rb

#puts "Content-type: text/html\r\n"
puts "Ruby:Hello World" + "<br>"

time1 = Time.new
puts "Current Time : " + time1.inspect + "<br>"

# Time.now is a synonym:
time2 = Time.now
puts "Current Time : " + time2.inspect + "<br>"

in ruby is no need to associate nothing you have already all done(in case you corrupt that you fix with this)在 ruby 中,无需关联您已经完成的任何操作(以防您损坏了您已修复的内容)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM