Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask can't find app file

Tags:

python

flask

In Step 2 of the official Flask tutorial, Flask cannot find my app file because it's looking in ../venv/Scripts/ instead of where I run the command. How can I tell Flask to look in the right place?

(venv) C:\Users\TomV\Codes\flaskr_tutorial>flask run
 * Serving Flask app "flaskr"
 * Forcing debug mode on
 * Restarting with stat
c:\users\tomv\codes\flaskr_tutorial\venv\scripts\python.exe: can't open file 'C:\Users\TomV\Codes\flaskr_tutorial\venv\Scripts\flask': [Errno 2] No such file or directory
like image 908
bongbang Avatar asked Jun 06 '16 05:06

bongbang


2 Answers

There seems to a bug according to this github issue:

https://github.com/pallets/flask/issues/1829

As a workaround you can do

>python -m flask run

You can also use >python -m flask initdb later in the tutorial, when initializing the database (step 4).

like image 154
Anders E. Andersen Avatar answered Sep 28 '22 02:09

Anders E. Andersen


You can give full path to app.py when you run "python app.py"

python C:/path/to/file/app.py
like image 39
BaagiK Avatar answered Sep 28 '22 01:09

BaagiK