Issue
I am getting the error
ImportError: cannot import name 'escape' from 'jinja2'
When trying to run code using the following requirements.txt:
chart_studio==1.1.0
dash==2.1.0
dash_bootstrap_components==1.0.3
dash_core_components==2.0.0
dash_html_components==2.0.0
dash_renderer==1.9.1
dash_table==5.0.0
Flask==1.1.2
matplotlib==3.4.3
numpy==1.20.3
pandas==1.3.4
plotly==5.5.0
PyYAML==6.0
scikit_learn==1.0.2
scipy==1.7.1
seaborn==0.11.2
statsmodels==0.12.2
urllib3==1.26.7
Tried
pip install jinja2
But the requirement is already satisfied.
Running this code on a windows system.
Solution
This happens because Jinja has removed those functions in a recent version — 3.1.0 — released on March 24th, 2022.
Markup
andescape
should be imported from MarkupSafe.
You have two options form here:
either this error comes from one of your dependency. The first thing you should consider is to upgrade the said dependence(s). If this is not possible, what you can do, from here is to downgrade your Jinja version to a version that would still include
escape
, for example, adding it explicitly in your requirements.txt:jinja2<3.1.0
or, your error is from code you wrote, so you can fix it by importing it from MarkupSafe, as suggested in the Jinja release notes.
So, you should use
from markupsafe import escape
instead of
from jinja2 import escape
Answered By - β.εηοιτ.βε
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.