First, note that I'm not trying to import Markup. I am trying to render a bootstrap modal with flask, after going through the documentation on PYPI about it... I'm making use of the
from flask_modals.modal import Modal
and all with the documentation Here However, I get an error
Traceback (most recent call last):
File "C:\Users\Samuel Osondu\PycharmProjects\ecommerceSite\main.py", line 7, in <module>
from flask_modals.modal import Modal
File "C:\Users\Samuel Osondu\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_modals\__init__.py", line 1, in <module>
from flask_modals.modal import (
File "C:\Users\Samuel Osondu\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_modals\modal.py", line 5, in <module>
from jinja2 import Markup
ImportError: cannot import name 'Markup' from 'jinja2' (C:\Users\Samuel Osondu\AppData\Local\Programs\Python\Python310\lib\site-packages\jinja2\__init__.py)
I've been trying to fix this for hours now, i've tried:
- Updating my Jinja
- Installing the Markup
- I've even changed the environment
Yet nothing, I sincerely do need help.
CodePudding user response:
After a lot of hassle, I finally found a way through it. The problem was actually coming from the flask file despite running on the current flask version.
I guess the flask_modal depended on the Markup package to run regardless of the fact that I didn't need to import it to run my code and as such... I clicked the location to the file
File "C:\Users\Samuel Osondu\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_modals\modal.py", line 5, in <module>
Then I changed the from from jinja2 import Markup
to from markupsafe import Markup
and this worked just fine!!