导入flask.ext会引发ModuleNotFoundError [英] Importing flask.ext raises ModuleNotFoundError

查看:86
本文介绍了导入flask.ext会引发ModuleNotFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Flask扩展名时,我的应用程序在from flask.ext.sqlalchemy import SQLAlchemyfrom flask.exthook import ExtDeprecationWarning等行上出现了ModuleNotFound错误.我安装了Flask和扩展程序.为什么会出现此错误?

When I try to use Flask extensions, my application is raising ModuleNotFound errors on lines like from flask.ext.sqlalchemy import SQLAlchemy or from flask.exthook import ExtDeprecationWarning. I have Flask and the extension installed. Why do I get this error?

推荐答案

您的代码中或您正在使用的代码中的某些内容正试图导入Flask 1.0中不再存在的flask.extflask.exthook.在显式弃用了至少一年之后,它们已被完全删除,在此之前隐式弃用了很多年.任何仍依赖它的东西都必须升级.

Something in your code, or in code you're using, is trying to import flask.ext or flask.exthook, which no longer exists in Flask 1.0. They were completely removed after being visibly deprecated for at least a year, and implicitly deprecated for many years before that. Anything that still depends on it must be upgraded.

使用from flask.ext import ...的任何方式都应替换为直接导入扩展名.例如,flask.ext.sqlalchemy变为flask_sqlalchemy.

Any use of from flask.ext import ... should be replaced with a direct import of the extension. For example flask.ext.sqlalchemy becomes flask_sqlalchemy.

导入from flask.exthook import ExtDeprecationWarning的唯一原因是使先前的弃用警告静音.由于不再存在,因此不会发出警告以保持静音,并且可以删除该代码.

The only reason to import from flask.exthook import ExtDeprecationWarning is to silence the previous deprecation warnings. Since it no longer exists, there is no warning to silence, and that code can be removed.

这篇关于导入flask.ext会引发ModuleNotFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆