ImportError: cannot import name 'escape' from 'jinja2'
07 Jan 2024, 19:09 UTC
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.
1 answer
Accepted answer · original discussion
10 Jan 2024, 19:09 UTC
Jinja is a dependency of Flask and Flask V1.X.X uses the escape module from Jinja, however recently support for the escape module was dropped in newer versions of Jinja.
To fix this issue, simply update to the newer version of Flask V2.X.X in your requirements.txt where Flask no longer uses the escape module from Jinja.
Flask>=2.2.2
Also, do note that Flask V1.X.X is no longer supported by the team. If you want to continue to use this older version, this Github issue may help.
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.