【问题标题】:Internal Server Error while running Python Program运行 Python 程序时出现内部服务器错误
【发布时间】:2021-12-31 15:14:03
【问题描述】:

我在 Windows 上运行 XAMPP,并尝试运行以下 python 代码,它给出 500 Internal Server Error,当我检查错误日志时它说:AH01909:www.example.com:443:0 服务器证书不包含与服务器匹配的 ID名称,[cgi:error] [pid 17416:tid 1836] (OS 5)访问被拒绝。 : [client ::1:1031] AH01223: 无法生成子进程:C:/xampp/htdocs/test.py

我的代码: #!C:/Users/Sravani/AppData/Local/Programs/Python/Python38-32 print ("内容类型:文本/html\n") 打印 (””) 打印 (””) 打印(“第一个 CGI 程序”) 打印 (””) 打印 (””) 打印 ("

你好

") 打印 (””) 打印 (””)

谁能在这方面帮助我

【问题讨论】:

    标签: python windows apache xampp cgi


    【解决方案1】:

    你可能应该检查它是否是错误的位置

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

    【讨论】:

    • 即使我试过 #!c:\users\sravani\AppData\Local\Programs\Phython\Python38-32
    • 我的 python 保存在这里
    【解决方案2】:

    使用我在这里发布的 install.bat : https://stackoverflow.com/a/71735909/5781320

    在 windows 10 x64+ apache + php 8.1 +... 和 python 正确关联我在我的 htdocs 中有一个文件夹测试,其中我有 2 个文件:

    index.php

    <?php
    
    // Highest priority
    proc_nice(-20);
    
    //echo shell_exec('index.rb');
    //system('index.rb');
    
    echo shell_exec('index.py');
    //system('index.py');
    
    
    ?>
    

    index.py

    print('Python:Hello, World!')

    通过在浏览器中调用 http://localhost/test/ 我运行了 python 脚本而不调用它 cgi (!#...)

    我让你阅读的 cmets 就位..

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

    因为我什至有 ruby​​ 和 index.rb 并且它们都在运行! (我不是 python 用户,也不是 ruby​​,但我通常会尝试一段时间 - 甚至 golang 看看有什么新东西..)

    index.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>"
    

    在 ruby​​ 中不需要关联你已经完成的任何事情(以防你损坏了你用这个修复的)

    【讨论】:

      猜你喜欢
      • 2020-12-18
      • 2013-12-05
      • 2013-09-18
      • 1970-01-01
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多