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.
The command
flask runstarted the app successfully.The command
flask db initfailed with the error reported in the question.So I tried
python run.pyand this failed to start the app by reporting an unmet dependency inmodels.pywhich was in fact a typo in an import. Fixing the typo and rerunningpython run.pywas successful.Then I tried
flask runagain, still fine. Thenflask db init... finally success.It appears the error reported that it could not find
run.pyis either misleading or masking the true root cause of why it could execute.