Python Flask使用数据迁移报错:ImportError: cannot import name ‘MigrateCommand‘ from ‘flask_migrate‘

Python Flask使用数据迁移报错:ImportError: cannot import name ‘MigrateCommand’ from ‘flask_migrate’

问题描述—ImportError: cannot import name ‘MigrateCommand’ from ‘flask_migrate’

报错信息:

image.png

问题原因

不支持 Flask-Script 的版本。

解决方法

切换到 Flask CLI 或将 Flask-Migrate 降级到版本 2.7.0,这是最后一个支持 Flask-Script 的版本。

pip install flask-migrate==2.7.0

也可以安装比这个版本低的版本

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
This error message indicates that there is an issue with importing the `current_app` object from the `flask` module. This object is used to access the current Flask application instance, and is typically used in a context where the application instance is not available through other means. There are a few possible reasons why you might encounter this error: 1. You may be importing `current_app` from the wrong module. Make sure that you are importing it from the `flask` module and not another module with a similar name. 2. You may be importing `current_app` before the Flask application has been created. `current_app` is only available when a Flask application context is active, so if you try to import it outside of a request or application context, you will get this error. Make sure that you are importing `current_app` from within a Flask view function, or from within a function that is called within a Flask view function. 3. There may be a circular import issue in your application. Flask applications can be prone to circular import issues if you're not careful about how you structure your code. If you're importing `current_app` from a module that also imports something from the module where your Flask application instance is created, you may run into this error. Try restructuring your code to avoid circular imports. To resolve this error, you should check your code for the above issues and make sure that you are importing `current_app` correctly and in the right context. You may also want to review the Flask documentation on application context and request context to better understand how they work.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Deng872347348

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值