cannot import name ‘escape’ from ‘jinja2’

I think you are getting this error

ImportError: cannot import name ‘escape’ from ‘jinja2’

 

There are two methods to solve this error cannot import name ‘escape’ from ‘jinja2’

1. Installing the jinja2 package using this pip command

pip install jinja2

 

2. Another method is updating the Flask version that is currently installed in your system. Using this command

pip install -Iv Flask==2.1.0

 

  • -I means --ignore-installed that will ignore the installed packages and overwriting them.
  • -v means verbose. You can combine up to 3 times (e.g. -Ivvv).

 

We are updating the flask to 2.X.X because Jinja is a dependency of flask and Flask 1.X.X versions use the escape module from jinja, But from the previous year the support of the escape module is deprecated in newer versions of Jinja. For fixing this issue, simply update the newer versions of Flask. And Flasks no longer utilizes the escape module from jinja. 

 

Also, read more about python.

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *