Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] import "Markup" fails when using Flask 3.0+ in __init__.py #157

Open
LeoNatanian opened this issue Mar 9, 2024 · 0 comments
Open
Labels

Comments

@LeoNatanian
Copy link

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:

  1. Install Flask 3.0 or better
  2. Install Flask-GoogleMaps
  3. 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant