I think Streamlit was not able to read the requirement.txt that is why it was showing No Module named matplotlib. When you shifted the files to the main directory it was able to detect the requirements.txt thus it resolved the issue.