1

I tries to run a cgi-script using this as server in python3:

from http.server import HTTPServer, CGIHTTPRequestHandler

port = 8080

httpd = HTTPServer(('', port), CGIHTTPRequestHandler)
print("Starting simple_httpd on port: " + str(httpd.server_port))
httpd.serve_forever()

but I got the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.2/http/server.py", line 1110, in run_cgi
    os.execve(scriptfile, args, env)
OSError: [Errno 2] No such file or directory
localhost - - [21/Nov/2012 10:28:26] CGI script exit status 0x7f00

Please Help.

4
  • 1
    Notice the error: No such file or directory. Check whether the file is there or not. Commented Nov 21, 2012 at 9:46
  • Can you let us know what's there in line 1110. Paste the content of that line here. Commented Nov 21, 2012 at 10:28
  • With the default settings if you are accessing hello.py then the file must be located as cgi-bin/hello.py . cgi-bin is a directory parallel to your server Commented Nov 21, 2012 at 10:49
  • This is what is in line 1110:os.execve(scriptfile, args, env) Commented Nov 21, 2012 at 11:50

1 Answer 1

5

hope these help: 1. check whether the script you are going to execute is executable? if it is not -rwx, it can not be execute 2. check the the top line of the script, i.e., #! ..... if this line does not correctly point to the folder of your python, it still can not be execute

Sign up to request clarification or add additional context in comments.

1 Comment

The path to the python binary was the problem in my case - really irritating that the error message states that the python file isn't there instead!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.