Prem asked this 6 months ago

Apache CGI Error: The system cannot find the file specified. couldn't spawn child process:

I'm trying to run the following "Hello world" Python cgi script

#!/usr/bin/env python

print "Content-Type: text/plain;charset=utf-8"
print

print """\
<html>
 <head>
  <title>Python - Hello World</title>
 </head>
 <body>
Hello World
 </body>
</html>
"""

 

and gets "Internal Server Error

Apache error log shows the following error message

[cgi:error] [pid 10068:tid 1140] (9)Bad file descriptor: [client ::1:54696] AH01222: don't know how to spawn child process: C:/httpd-2.4.37-win64-VC15/Apache24/cgi-bin/hello.py

Am I missing something in .conf?


Best Answer by rijo 6 months ago

it looks like you are running Apache on windows because the error message say c:\httpd-2.4.37-win64-VC15 however your hashbang on the first line of the script is for linux/unix installation of Python

change

 #!/usr/bin/env python

to

#! c:/your/windows/python/install_directory

cheers

Rijo

Prem 6 months ago

Thanks, for your quick response Rijo.!! 

It was really stupid of me. changed the first line to  #!C:\Python26\Python and it worked!!