Lame-Ov2.0 Lame-Ov2.0 - 1 year ago 124
Python Question

Python script: problems with shebang line (unix)

I am trying to get a feel for the Flask microframework by launching a test application to local server. When trying to run my code,
, I keep getting the error message:

-bash: ./ /flask/bin/python: bad interpreter: No such file or directory

Here is the basic code (taken from here) for
, which lives in my todo-api directory:

from flask import Flask

app = Flask(__name__)

def index():
return "Hello, World!"

if __name__ == '__main__':

I've checked the file path to the python interpreter, and it should exist:

:bin $ pwd python


I have followed the tutorial to the T; I've tried changing the shebang line to:

#!/flask/bin/env python

But to no avail. I am not that knowledgeable about bash, and have tried looking up what is going on, but the solutions to folks with similar problems have not worked for me; is there something going on behind the scenes that I am not understanding?

Answer Source

Bash shebangs expect an absolute path to the interpreter. So in your case you need to specify the full path to your Python interpreter i.e.:


You might want to investigate the use of /usr/bin/env python to be able to use the interpreter that is available in your user's $PATH environment variable. See

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download