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

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


In my case I had to do

python3 -m flask db init

Without mentioning python3 -m, it shows

zsh: command not found: flask


The command flask run started the app successfully.

The command flask db init failed with the error reported in the question.

So I tried python run.py and this failed to start the app by reporting an unmet dependency in models.py which was in fact a typo in an import. Fixing the typo and rerunning python run.py was successful.

Then I tried flask run again, still fine. Then flask db init... finally success.

It appears the error reported that it could not find run.py is either misleading or masking the true root cause of why it could execute.


In my case my app name was different, and in the directory, I had two flask apps app.py and app_async.pyAnd I was also getting the same migrate key error, so this is how I solved it:

FLASK_APP=app_async.py flask db init

Here I mentioned the app name, and then ran the command.