ImportError: cannot import name ‘makeMappingArray’ from ‘matplotlib.colors’

I got an error when running my app on my local machine and when deploying on streamlit:

ImportError: cannot import name ‘makeMappingArray’ from ‘matplotlib.colors’ (/home/appuser/venv/lib/python3.7/site-packages/matplotlib/colors.py)

According to Matplotlib, the function was deprecated since V3.34. See here. On my local machine, I had to copy-paste the function to the colors.py file for it to run. I got the function from this site.

In my code, I imported *matplotlib.pyplot as plt but never did I call the makeMappingArray function. Why does the streamlit app still need it to run both locally and on the streamlit sharing platform? How can it be corrected?