Solution skill
ImportError: cannot import name 'Markup' from 'flask'
Complete solution
Fixes ImportError: cannot import name 'Markup' from 'flask' Use when Flask 3.x and anything doing `from flask import Markup` Not for: Flask < 3 (it warns but works)
How to fix ImportError: cannot import name 'Markup' from 'flask'
Flask 3 removed the flask.Markup re-export. Change from flask import Markup to from markupsafe import Markup. If it is a third-party extension (Flask-GoogleMaps, etc.), upgrade the extension; patching your own import takes ten seconds.
The exact error
ImportError: cannot import name 'Markup' from 'flask'Fix it
grep -rn "from flask import" --include=*.py . | grep Markupto find all occurrences. Expected: list of filesReplace with
from markupsafe import Markup. Expected: app imports cleanly, tests passExtension-owned?
pip install -U [extension]. Expected: upstream fix
When this applies
Flask 3.x and anything doing from flask import Markup
When this does NOT apply
Flask < 3 (it warns but works)
Versions
Flask >= 3.0 (deprecated since 2.0)
Why it happens
Flask deprecated re-exporting markupsafe names in 2.0, removed in 3.0.
Edge cases
markupsafe.Markup is the same class; behavior is identical.
Evidence
Asked about: ImportError: cannot import name 'Markup' from 'flask' (gh:flask-extensions/Flask-GoogleMaps#157). The verified fix: Flask 3 removed the flask.Markup re-export. Change from flask import Markup to from markupsafe import Markup. If it is a third-party extension (Flask-GoogleMaps, etc.), upgrade the extension; patching your own import takes ten seconds. Full thread: https://github.com/flask-extensions/Flask-GoogleMaps/issues/157
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_NvYnRfnbpm7Lweh2qlgjLA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ImportError: cannot import name 'Markup' from 'flask' <span>— Vectle</span></a>