繁体   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