gpt4 book ai didi

python - flask.ext.script 已弃用

转载 作者:太空狗 更新时间:2023-10-30 02:38:36 26 4
gpt4 key购买 nike

我有以下错误:

web_1  | /code/app/__init__.py:4: ExtDeprecationWarning: Importing flask.ext.script is deprecated, use flask_script instead.
web_1 | from flask.ext.script import Manager
web_1 | Traceback (most recent call last):
web_1 | File "run.py", line 2, in <module>
web_1 | from app import app
web_1 | File "/code/app/__init__.py", line 4, in <module>
web_1 | from flask.ext.script import Manager
web_1 | File "/usr/local/lib/python3.6/site-packages/flask/exthook.py", line 110, in load_module
web_1 | raise ImportError('No module named %s' % fullname)
web_1 | ImportError: No module named flask.ext.script

然后我进行了更改,但随后显示:

web_1  | Traceback (most recent call last):
web_1 | File "run.py", line 2, in <module>
web_1 | from app import app
web_1 | File "/code/app/__init__.py", line 4, in <module>
web_1 | from flask_script import Manager
web_1 | ModuleNotFoundError: No module named 'flask_script'

我对 Flask 是如何升级的有点困惑。有什么建议吗?我是否应该将我的 flask 修复到旧版本,也许依赖项尚未升级?

使用 sqlalchemy 和迁移:

from flask import Flask
from flask_ext.script import Manager
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.migrate import Migrate, MigrateCommand

最佳答案

我必须显式安装 Flask-Script

然后导入可以使用

from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate, MigrateCommand

关于python - flask.ext.script 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46534046/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com