python - Flask-Migrate 命令 'flask db init' 找不到应用程序文件

标签 python flask flask-sqlalchemy flask-migrate

首先,我正在关注此处发布的 Python Flask 教程:https://scotch.io/tutorials/build-a-crud-web-app-with-python-and-flask-part-one .

一切顺利,直到“迁移”部分执行:

$ flask db init

...因以下错误而失败:

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

我知道 $FLASK_APP 环境变量已设置,因为此命令执行良好:

$ flask run

谁能提出为什么这在运行应用程序时执行良好,但在尝试创建迁移存储库时执行不正常?

关于这个主题,我能在其他地方找到的最接近的是:Flask can't find app file ,但在这两种情况下,用 python -m 预先挂起对我来说都不起作用。

最佳答案

在我的情况下,我必须这样做

python3 -m flask db init

不用说python3 -m,就显示

zsh: command not found: flask

关于python - Flask-Migrate 命令 'flask db init' 找不到应用程序文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41442616/

相关文章:

python - 如何将 Python 列表转换为 Python Dataframe?

python - 如何在 Python 中使用 boolean 值?

python - Flask-Restful - 返回带有嵌套数组的 json

python - 保存图像文件时 Flask 出现错误 "ValueError: read of closed file"

python - Flask 和 SQLAlchemy 在 PostgreSQL 的事务连接中导致大量 IDLE

python - flask-admin 表单 : Constrain Value of Field 2 depending on Value of Field 1

python - Flask View 测试 : How do I prevent data from being saved to the database?

python - PIP无法安装auto-py-to-exe

python - Boto - 从 S3 抓取最新的

python - 在 Python 3.7 中将字典追加到列表中