Why I get error when I import matplotlib.pyplot in my github directory?

Could anyone help me with this.
My python script works fine till I try to import matplotlib.
Adding this line
import matplotlib.pyplot as plt

creates error:

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
  File "/app/streamlite_test/streamlit_app1.py", line 3, in <module>
    import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'

Because matplotlib. is not installed

It did help, thank you. I added file requirements.txt to a directory with my Python script, and it worked. I used this requirements.txt:
numpy
pandas
Pillow
matplotlib
streamlit

1 Like