0

I keep receiving the following error when running the command flask run in my venv. I have tried reinstalling the program multiple times and can not get it to work. I got it to work once then tried switching into development mode from production mode per my instructor and now receive the following error everytime I try running flask.

Traceback (most recent call last):
  File "/Users/rachelpoverman/Desktop/Software Engineering Projects/Unit_22_Flask/22.1-intro/flask-intro-demo/video-demo/venv/bin/flask", line 7, in <module>
    from flask.cli import main
  File "/Users/rachelpoverman/Desktop/Software Engineering Projects/Unit_22_Flask/22.1-intro/flask-intro-demo/video-demo/venv/lib/python3.11/site-packages/flask/__init__.py", line 14, in <module>
    from jinja2 import escape
ImportError: cannot import name 'escape' from 'jinja2' (/Users/rachelpoverman/Desktop/Software Engineering Projects/Unit_22_Flask/22.1-intro/flask-intro-demo/video-demo/venv/lib/python3.11/site-packages/jinja2/__init__.py)
rpovie
  • 1
  • 2
  • 1
    Does this answer your question? [ImportError: cannot import name 'escape' from 'jinja2'](https://stackoverflow.com/questions/71718167/importerror-cannot-import-name-escape-from-jinja2) – Tsyvarev Jul 24 '23 at 18:43

1 Answers1

0

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.X.X

Also, do note that Flask V1.X.X is no longer supported by the team.

dsdaksh
  • 1
  • 1