I m facing the issue on Flask, when I try to import flask
from flask import Flask
and it gives this error:
Traceback (most recent call last):
File "<path to project>\main.py", line 1, in <module>
from flask import Flask, render_template, request, redirect, url_for
File "<path to project>\venv\lib\site-packages\flask\__init__.py", line 19, in <module>
from jinja2 import Markup, escape
ImportError: cannot import name 'Markup' from 'jinja2' (<path to project>\venv\lib\site-packages\jinja2\__init__.py)
I confirmed that flask is on the latest version and markupsafe is installed I tried uninstalling and reinstalling The issue started after reinstalling pycharm
CodePudding user response:
jinja2.Markup
was removed in version 3.1.0; see the changelog: https://jinja.palletsprojects.com/en/3.1.x/changes/#version-3-1-0
It should be imported directly from the markupsafe
package instead, which I believe was split off from Jinja as a separate package some time ago.
CodePudding user response:
This can usually be solved by uninstalling and reinstalling python and installing Flask package to latest version