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.

Answer from Ryan on Stack Overflow
Discussions

Can't import 'escape' from 'jinja2'
Hey there so I'm trying to get the web ui to run and I'm just getting this: user@server:~ $ sudo nxbt webapp Traceback (most recent call last): File "/usr/local/bin/nxbt", line 8, in sys.e... More on github.com
🌐 github.com
11
May 18, 2023
cannot import name 'escape' from 'jinja2'
Hi. I am trying to install sdss-marvin in my Ubuntu system. But it is showing me the following error: [ERROR]: Traceback (most recent call last): File "/home/krittika/.local/bin/run_marvin", line 2... More on github.com
🌐 github.com
9
September 2, 2023
[Support] cannot import name 'escape' from 'jinja2'
Describe the bug Objection Currently Using escape which is improted from MarkUP from markupsafe import escape Solution pip install Jinja2==3.0.3 Expected behavior ImportError: cannot import name &#... More on github.com
🌐 github.com
0
March 18, 2024
ImportError: cannot import name 'escape' from 'jinja2' after upgrading to 3.1.0
Describe how to replicate the bug. The import works with 3.0.3 (env) cl-akshayjain:tests ajain$ pip freeze | grep Jinja2 Jinja2==3.0.3 (env) cl-akshayjain:tests ajain$ python Python 3.7.4 (default, Sep 7 2019, 18:27:02) [Clang 10.0.1 (cl... More on github.com
🌐 github.com
2
March 24, 2022
🌐
GitHub
github.com › pallets › jinja › issues › 1626
ImportError: cannot import name 'escape' from 'jinja2' · Issue #1626 · pallets/jinja
March 24, 2022 - ImportError: cannot import name 'escape' from 'jinja2'#1626 · Copy link · bilykigor · opened · on Mar 24, 2022 · Issue body actions · Environment: Python version: 3.7 · Jinja version: 3.1.0 · Reactions are currently unavailable · No one assigned · No labels · No labels ·
Author   pallets
🌐
Medium
medium.com › @pies052022 › importerror-cannot-import-name-markup-from-jinja2-8bf9efb225d7
ImportError: cannot import name ‘Markup’ from ‘jinja2′ | by JOKEN VILLANUEVA | Medium
October 27, 2025 - ImportError: cannot import name ‘Markup’ from ‘jinja2′ Cannot Import Name Markup From jinja2 error happens because some of Jinja’s internal modules were changed in a recent release. In one …
🌐
Bobby Hadz
bobbyhadz.com › blog › python-importerror-cannot-import-name-escape-from-jinja2
ImportError cannot import name escape & Markup from jinja2 | bobbyhadz
April 10, 2024 - The ImportError: cannot import name 'escape' from 'jinja2' is caused because the `escape` function was removed in version 3.1.0 of `jinja2`.
🌐
GitLab
gitlab.servus.at › aura › engine › #106
ImportError: cannot import name 'escape' from 'jinja2' (#106) · Issues · AURA / engine · GitLab
Some dependency seems to have introduced a conflict. When rebuilding the docker-image (thus freshly installing all dependencies) starting it now fails with the following error:
Find elsewhere
🌐
Itsourcecode
itsourcecode.com › home › importerror: cannot import name ‘escape’ from ‘jinja2’
Importerror: cannot import name 'escape' from 'jinja2' [SOLVED]
April 28, 2023 - [FIXED] Importerror: cannot import name 'escape' from 'jinja2' can be fixed by refactoring the import statement and downgrading the Jinja2 version.
🌐
GitHub
github.com › Brikwerk › nxbt › issues › 121
Can't import 'escape' from 'jinja2' · Issue #121 · Brikwerk/nxbt
May 18, 2023 - user@server:~ $ sudo nxbt webapp Traceback (most recent call last): File "/usr/local/bin/nxbt", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.9/dist-packages/nxbt/cli.py", line 321, in main from .web import start_web_app File "/usr/local/lib/python3.9/dist-packages/nxbt/web/__init__.py", line 1, in <module> from .app import start_web_app File "/usr/local/lib/python3.9/dist-packages/nxbt/web/app.py", line 9, in <module> from flask import Flask, render_template, request File "/usr/local/lib/python3.9/dist-packages/flask/__init__.py", line 14, in <module> from jinja2 import escape ImportError: cannot import name 'escape' from 'jinja2' (/usr/local/lib/python3.9/dist-packages/jinja2/__init__.py)
Author   Brikwerk
🌐
GitHub
github.com › sdss › marvin › issues › 800
cannot import name 'escape' from 'jinja2' · Issue #800 · sdss/marvin
September 2, 2023 - [ERROR]: Traceback (most recent call last): File "/home/krittika/.local/bin/run_marvin", line 20, in from marvin.web import create_app File "/home/krittika/.local/lib/python3.10/site-packages/marvin/init.py", line 29, in from brain.utils.general.general import getDbMachine File "/home/krittika/.local/lib/python3.10/site-packages/brain/utils/general/init.py", line 2, in from brain.utils.general.general import * File "/home/krittika/.local/lib/python3.10/site-packages/brain/utils/general/general.py", line 12, in from flask import url_for File "/home/krittika/.local/lib/python3.10/site-packages/flask/init.py", line 14, in from jinja2 import escape ImportError: cannot import name 'escape' from 'jinja2' (/usr/local/lib/python3.10/dist-packages/jinja2/init.py)
Author   sdss
🌐
Itsourcecode
itsourcecode.com › home › importerror: cannot import name ‘environmentfilter’ from ‘jinja2’
Importerror: cannot import name 'environmentfilter' from 'jinja2' - Itsourcecode.com
May 2, 2023 - [SOLVED] Importerror: cannot import name 'environmentfilter' from 'jinja2' error can be caused by version conflicts or incorrect installation of Jinja2.
🌐
Python Pool
pythonpool.com › home › blog › troubleshooting “cannot import name ‘escape’ from ‘jinja2′” error
Troubleshooting "Cannot import name 'escape' from 'jinja2'" Error
February 5, 2023 - To fix this, updating the Jinja2 library to the latest version will resolve this. In certain cases, the error message may appear due to conflicting modules within a project, which can cause issues with import statements.
🌐
Google Groups
groups.google.com › g › django-users › c › pytjLOVUwmM
Jinja2 with Django 1.8c1 & cannot import name 'Environment'
Hi Rolf, Since your `jinja2.py` file sits before your installed `jinja2` package directory in your PYTHONPATH you end up trying to import `Environement` from your the module you're defining and not the installed `jinja2` module. Rename your jinja2.py file something else and things should be working.
🌐
GitHub
github.com › sensepost › objection › issues › 671
[Support] cannot import name 'escape' from 'jinja2' · Issue #671 · sensepost/objection
March 18, 2024 - Describe the bug Objection Currently Using escape which is improted from MarkUP from markupsafe import escape Solution pip install Jinja2==3.0.3 Expected behavior ImportError: cannot import name 'escape' from 'jinja2' (C:\Users_\AppData\...
Author   sensepost
🌐
51CTO
blog.51cto.com › u_15870497 › 5926999
Flask安装时候出现这个问题,安装的版本是flask==1.1.2版本 ...
December 10, 2022 - The security policy of this website has blocked you from further access. Contact the site owner and provide the Request ID shown on this page · If you are the owner of this website: Refer to the EdgeOne Web Security Analytics documentation for further instructions
🌐
GitHub
github.com › pallets › jinja › issues › 1633
ImportError: cannot import name 'escape' from 'jinja2' after upgrading to 3.1.0 · Issue #1633 · pallets/jinja
March 24, 2022 - (env) cl-akshayjain:tests ajain$ pip freeze | grep Jinja2 Jinja2==3.0.3 (env) cl-akshayjain:tests ajain$ python Python 3.7.4 (default, Sep 7 2019, 18:27:02) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from jinja2 import escape >>> exit()
Author   pallets
🌐
CSDN
blog.csdn.net › ZhangUxian › article › details › 126501253
安装flask遇到cannot import name ‘escape‘ from ‘jinja2‘ 的问题_cannot import name 'escape' from 'jinja2-CSDN博客
August 24, 2022 - 查下现在jinja更到了哪个版本,或者看看自己的python版本与哪个jinja版本适用,再改一下上面命令里的版本号就OK啦。如果没有解决,这个问题是因为jinjia版本与自己的python版本不合造成的。第一步——先卸载已经安装的jinja2: pip uninstall jinja2。第二步——安装3.0.3版本: pip install jinja2==3.0.3开始就是学flask,很简单,也方便理解后面的内容。平常没事也可以做一些小网站,非常方便。今天打开一个项目的时候,发生了如题报错。 · ImportError: cannot import name ‘escape‘ from ‘jinja2‘
🌐
51CTO
blog.51cto.com › u_15677788 › 5437034
cannot import name 'escape' from 'jinja2'【成功解决】
July 3, 2022 - The security policy of this website has blocked you from further access. Contact the site owner and provide the Request ID shown on this page · If you are the owner of this website: Refer to the EdgeOne Web Security Analytics documentation for further instructions
🌐
Brainly
brainly.com › computers and technology › high school › importerror: cannot import name 'escape' from 'jinja2'.
[FREE] ImportError: Cannot import name 'escape' from 'jinja2'. - brainly.com
TheImportError for 'escape' from 'jinja2' usually occurs due to changes in the Jinja2 library where 'escape' has moved to the 'markupsafe' module. To fix it, you should import 'escape' from 'markupsafe' instead.