flask-example icon indicating copy to clipboard operation
flask-example copied to clipboard

Outdated Dependencies - ImportError: cannot import name 'escape' from 'jinja2'

Open TunaCici opened this issue 2 years ago • 0 comments

Following the guide, the application fails to launch due to "old" dependencies. Here's the exact error

Traceback (most recent call last):
  File "/home/<uname>/flask-example/app.py", line 4, in <module>
    from flask import Flask, session, url_for, redirect, render_template, request, abort, flash
  File "/home/<uname>/.local/lib/python3.9/site-packages/flask/__init__.py", line 14, in <module>
    from jinja2 import escape
ImportError: cannot import name 'escape' from 'jinja2' (/home/<uname>/.local/lib/python3.9/site-packages/jinja2/__init__.py)

Shouldn't matter too much, but here's my system information (running Ubuntu 22.04 LTS on Raspi 4b):

python3 -- version
> Python 3.9.2

python3 -m pip --version
> pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)

uname -a
> Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux

lsb_release -a
> Distributor ID:	Debian
> Description:	Debian GNU/Linux 11 (bullseye)
> Release:	11
> Codename:	bullseye

I believe this is due to Flask version being too "old". Upgrading to newer version (e.g. =< 2.0) should fix the problem.

TunaCici avatar Jan 18 '24 09:01 TunaCici