1

I want to run a scripts that require Jinja2 so it can runs properly. However, i am having the following error:

cannot import name 'Markup' from 'jinja2.utils' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jinja2/utils.py)

Several solutions that i have tried and don't work:

pip uninstall  Flask Jinja2 
pip install  Flask Jinja2

tried to implement the following line of code in my core.py:

from jinja2.utils import markupsafe
markupsafe.Markup()

and it returns different error:

module 'jinja2.ext' has no attribute 'autoescape'

I don't know what went wrong or if i have Jinja not properly installed. I am not sure if modifying the code would fix the problem and not making another.

how do i resolve this?

Update: tried to execute pip freeze and it returns the following output:

anyio==3.6.1
appnope==0.1.3
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
asttokens==2.0.5
attrs==22.1.0
Babel==2.10.3
backcall==0.2.0
beautifulsoup4==4.11.1
bleach==5.0.1
cachetools==5.2.0
certifi==2022.6.15
cffi==1.15.1
charset-normalizer==2.1.0
click==8.1.3
debugpy==1.6.2
decorator==5.1.1
defusedxml==0.7.1
entrypoints==0.4
executing==0.9.1
fastjsonschema==2.16.1
Flask-SQLAlchemy==2.5.1
google==3.0.0
google-api-core==2.10.0
google-api-python-client==2.58.0
google-auth==2.11.0
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.5.2
googleapis-common-protos==1.56.4
greenlet==1.1.3
httplib2==0.20.4
idna==3.3
ipykernel==6.15.1
ipython==8.4.0
ipython-genutils==0.2.0
itsdangerous==2.1.2
jedi==0.18.1
Jinja2==3.1.2
jinjasql==0.1.8
json5==0.9.9
jsonschema==4.9.0
jupyter-client==7.3.4
jupyter-core==4.11.1
jupyter-server==1.18.1
jupyterlab==3.4.4
jupyterlab-pygments==0.2.2
jupyterlab-server==2.15.0
MarkupSafe==2.1.1
matplotlib-inline==0.1.3
mistune==0.8.4
mysql-connector-python-rf==2.2.2
nbclassic==0.4.3
nbclient==0.6.6
nbconvert==6.5.0
nbformat==5.4.0
nest-asyncio==1.5.5
notebook==6.4.12
notebook-shim==0.1.0
numpy==1.23.2
oauthlib==3.2.0
packaging==21.3
pandas==1.4.4
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
prometheus-client==0.14.1
prompt-toolkit==3.0.30
protobuf==4.21.5
psutil==5.9.1
psycopg2-binary==2.9.3
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
Pygments==2.12.0
pygsheets==2.0.5
pyparsing==3.0.9
pyrsistent==0.18.1
python-dateutil==2.8.2
pytz==2022.1
pyzmq==23.2.0
requests==2.28.1
requests-oauthlib==1.3.1
rsa==4.9
Send2Trash==1.8.0
six==1.16.0
sniffio==1.2.0
soupsieve==2.3.2.post1
SQLAlchemy==1.4.40
stack-data==0.3.0
terminado==0.15.0
tinycss2==1.1.1
tornado==6.2
traitlets==5.3.0
uritemplate==4.1.1
urllib3==1.26.11
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.3.3
Werkzeug==2.2.2

found another solutions:

With Jinja2 3.1, WithExtension and AutoEscapeExtension are built-in now. So you don't need these extensions anymore. Delete these extension from babel.cfg file

[python: **.py]
[jinja2: **/templates/**.html]
;extensions=jinja2.ext.auto escape,jinja2.ext.with_

Update: somehow i found the solutions: https://stackoverflow.com/posts/72439592/revisions

0 Answers0