ImportError: Missing optional dependency 'Jinja2'. DataFrame.style requires jinja2. Use pip or conda to install Jinja2

I was simply going to run my streamlit app with this code

streamlit run app.py

But then got this error:
Traceback (most recent call last):
File “C:\Users\marsa\anaconda3\envs\marsa\lib\runpy.py”, line 193, in run_module_as_main
main”, mod_spec)
File “C:\Users\marsa\anaconda3\envs\marsa\lib\runpy.py”, line 85, in run_code
exec(code, run_globals)
File "C:\Users\marsa\anaconda3\envs\marsa\Scripts\streamlit.exe_main
.py", line 4, in
File "C:\Users\marsa\anaconda3\envs\marsa\lib\site-packages\streamlit_init
.py", line 70, in
from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
File “C:\Users\marsa\anaconda3\envs\marsa\lib\site-packages\streamlit\delta_generator.py”, line 89, in
from streamlit.elements.arrow import ArrowMixin
File “C:\Users\marsa\anaconda3\envs\marsa\lib\site-packages\streamlit\elements\arrow.py”, line 21, in
from pandas.io.formats.style import Styler
File “C:\Users\marsa\anaconda3\envs\marsa\lib\site-packages\pandas\io\formats\style.py”, line 49, in
jinja2 = import_optional_dependency(“jinja2”, extra=“DataFrame.style requires jinja2.”)
File “C:\Users\marsa\anaconda3\envs\marsa\lib\site-packages\pandas\compat_optional.py”, line 118, in import_optional_dependency
raise ImportError(msg) from None
ImportError: Missing optional dependency ‘Jinja2’. DataFrame.style requires jinja2. Use pip or conda to install Jinja2.

What I could figure out is that I have installed my jinja2 package so I tried installing that package again and it gave me the same error. Any solutions to this?

Seems to be a common problem with the latest version of jinja2.

Try this:

pip3 install jinja2==3.0.1