4

I am new to Flask and Babel and I have just started a project which will contain several languages. After I have generated the babel.cfg file, when I attempt to extract it with the command pybabel extract -F babel.cfg -o messages.pot ., I get the AttributeError: module 'jinja2.ext' has no attribute 'autoescape' error.

What can be the reason for this error and how can I fix it?

Thank you

mbaki
  • 57
  • 1
  • 5

2 Answers2

9

With Jinja2 3.1, WithExtension and AutoEscapeExtension are built-in now. So you don't need these extensions anymore. Delete these extension from babel.cfg file

[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

ulas.kesik
  • 148
  • 1
  • 5
1

I assume that you are using Python 3.10 and Jinja2 version >= 3.x.x

The extension jinja2.ext.autoescape and jinja2.ext.withhave been deprecated with Jinja2 version 3.0.0! They have been added to the compiler.

Link to changes: https://jinja.palletsprojects.com/en/3.1.x/changes/#version-3-0-0

mataleon
  • 11
  • 1