简体   繁体   中英

How to make a py script executable on Wamp

I am getting file not executable error when try to run python via Apache on WAMP. Following is error message in 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 file

#!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 module already enabled.

Necropost but this is first link google. So you just need to add space after #! it should look like "#! c:\\blablabla" instead of "#!c:\\blablabla". That`s all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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