Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No such file or directory with Flask

Tags:

python

flask

flask question: I have my run.py file in the following dir

 /Users/`<username>`/Python_stuff/flask

but when I run it it says

(api_automation)MacBook-Pro:flask `<username>`$ ./run.py
-bash: ./run.py: flask/bin/python: bad interpreter: No such file or directory

I'm confused as to why this is happening when its worked in the past on other virtualenv's

here is what the run.py looks like:

#!flask/bin/python

from app import app 
app.run(debug = True)
like image 907
Lombax Avatar asked Jul 22 '14 16:07

Lombax


1 Answers

Your file starts with a shebang telling the shell what program to load to run the script. The shebang line is the first line starting with #!.

In this case, the shebang tells the shell to run flask/bin/python, and that file does not exist in your current location.

The tutorial you got this from expects you to create a virtualenv directory called flask, and the script is set up to run the Python binary installed in that directory.

If you are using a different Python location, edit the shebang line to point to the correct location, or use python run.py to explicitly name the executable on the command line. In that case the shebang line is ignored.

like image 168
Martijn Pieters Avatar answered Nov 08 '22 01:11

Martijn Pieters