Flask-Migrate command 'flask db init' can't find app file

mcorrigal picture mcorrigal · Jan 3, 2017 · Viewed 10.2k times · Source

Firstly, I'm following the Python Flask tutorial posted here: https://scotch.io/tutorials/build-a-crud-web-app-with-python-and-flask-part-one.

Everything was working smoothly up to the 'Migration' section where executing:

$ flask db init

... failed with the following error:

Usage: flask db init [OPTIONS]

Error: The file/path provided (run) does not appear to exist.  Please verify the path is correct.  If app is not on PYTHONPATH, ensure the extension is .py

I know the $FLASK_APP env variable is set because this command executes fine:

$ flask run

Can anyone suggest why this executes fine when running the app, but not when trying to create the migration repository?

The closest I can find elsewhere on the subject is here: Flask can't find app file, but pre-pending with python -m isn't working in either case for me here.

Answer

kurosaki_007 picture kurosaki_007 · Feb 1, 2020

In my case I had to do

python3 -m flask db init

Without mentioning python3 -m, it shows

zsh: command not found: flask