我是 Flask 和 Babel 的新手,我刚刚开始了一个包含多种语言的项目。生成 babel.cfg 文件后,当我尝试使用命令 pybabel extract -F babel.cfg -o messages.pot .
提取它时,我得到了 AttributeError: module ' jinja2.ext' 没有属性 'autoescape'
错误。
出现此错误的原因是什么,我该如何解决?
谢谢
最佳答案
在 Jinja2 3.1
中,WithExtension
和 AutoEscapeExtension
现在是内置的。所以你不再需要这些扩展。
从 babel.cfg 文件中删除这些扩展
[python: **.py]
[jinja2: **/templates/**.html]
;extensions=jinja2.ext.auto escape,jinja2.ext.with_
https://jinja.palletsprojects.com/en/3.1.x/changes/#version-3-0-0
关于python - 属性错误 : module 'jinja2.ext' has no attribute 'autoescape' while trying to use Flask-Babel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72651555/