簡體   English   中英

如何在Wamp上使py腳本可執行

[英]How to make a py script executable on Wamp

嘗試通過WAMP上的Apache運行python時,出現文件不可執行錯誤。 以下是access_log中的錯誤消息:

[Fri Jan 17 00:31:57.358375 2014] [cgi:error] [pid 2972:tid 612] [client 127.0.0.1:3495] script not found or unable to stat: C:/wamp/www/python.py
[Fri Jan 17 00:32:26.483375 2014] [win32:error] [pid 2972:tid 612] [client 127.0.0.1:3496] AH02102: C:/wamp/www/python.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
[Fri Jan 17 00:32:26.483375 2014] [cgi:error] [pid 2972:tid 612] (9)Bad file descriptor: [client 127.0.0.1:3496] AH01222: don't know how to spawn child process: C:/wamp/www/python.py
[Fri Jan 17 00:32:29.327125 2014] [win32:error] [pid 2972:tid 612] [client 127.0.0.1:3497] AH02102: C:/wamp/www/python.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
[Fri Jan 17 00:32:29.327125 2014] [cgi:error] [pid 2972:tid 612] (9)Bad file descriptor: [client 127.0.0.1:3497] AH01222: don't know how to spawn child process: C:/wamp/www/python.py

httpd.conf

DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
    AddHandler cgi-script .cgi .py
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks ExecCGI
    #Options +Indexes FollowSymLinks +ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
#    Require all granted
#   onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost
</Directory>

py文件

#!C:\Python32\python.exe

print "Content-type: text/html"
print ""
print "<html>"
print "<head>"
print "<title>CGI Test of Python1</title>"
print "</head>"
print "<body>"
print "This is a test"
print "</body>"
print "</html>"

cgi模塊已啟用。

Necropost,但這是google的第一鏈接。 因此,您只需要在#之后添加空格! 它應該看起來像“#!c:\\ blablabla”,而不是“#!c:\\ blablabla”。 僅此而已。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM