Describe the bugImportError: cannot import name 'Markup' from 'flask' (/home/lnatanian/dev/project/venv/lib/python3.12/site-packages/flask/__init__.py)
Since Flask is using Jinja2 for quite some time, they removed the re-export of Markup with the 3.0.0 release, see GitHub.
To Reproduce
Steps to reproduce the behavior:
Install Flask 3.0 or better
Install Flask-GoogleMaps
Attempt to import googlemaps in your init.
Expected behavior
GoogleMaps should work with Flask version 3.0+
Workaround
I modified __init__.py in the Flask-GoogleMaps app and imported from another pip package called markupsafe. This may have introduced a new dependency though.
from json import dumps
import requests as rq
import requests
# MODIFIED-Importing Markup from another Package
from markupsafe import Markup
from flask import Blueprint, g, render_template
from flask_googlemaps.icons import dots
Traceback
Traceback (most recent call last):
File "/home/lnatanian/dev/project/main.py", line 1, in <module>
from app import app
File "/home/lnatanian/dev/project/app/__init__.py", line 7, in <module>
from flask_googlemaps import GoogleMaps
File "/home/lnatanian/dev/project/venv/lib/python3.12/site-packages/flask_googlemaps/__init__.py", line 9, in <module>
from flask import Blueprint, Markup, g, render_template
ImportError: cannot import name 'Markup' from 'flask' (/home/lnatanian/dev/project/venv/lib/python3.12/site-packages/flask/__init__.py)
Describe the bug
ImportError: cannot import name 'Markup' from 'flask' (/home/lnatanian/dev/project/venv/lib/python3.12/site-packages/flask/__init__.py)
Since Flask is using Jinja2 for quite some time, they removed the re-export of Markup with the 3.0.0 release, see GitHub.
To Reproduce Steps to reproduce the behavior:
Expected behavior GoogleMaps should work with Flask version 3.0+
Workaround I modified
__init__.py
in the Flask-GoogleMaps app and imported from another pip package called markupsafe. This may have introduced a new dependency though.Traceback