File not found error, but file exists

5.3k views Asked by At

I am working on a simple webapp from Head First Python. I am using ubuntu 14.04. But it is the error:

Traceback (most recent call last):
  File "/usr/lib/python3.4/http/server.py", line 1143, in run_cgi
    os.execve(scriptfile, args, env)
FileNotFoundError: [Errno 2] No such file or directory: 
'/home/sarthak/Desktop/Learn/HeadFirstPython/chapter7/webapp/cgi-bin/generate_list.py'

127.0.0.1 - - [12/Jun/2015 07:08:25] CGI script exit status 0x7f00

The file surely exists on the system and it is made executable.

How to fix the problem?

1

There are 1 answers

1
mirirai On BEST ANSWER

The Problem lies in the 'wrong' path of the shebang line (the first line which says #!/usr/local/bin/python3) of the generate_list.py file.

If you are using ubuntu the location of python3 is probably /usr/bin/python3 (You can find out your python3 location by typing which python3 into the shell/terminal). So you have to adjust the first line to the actual address of python3 in order to make your script work.