ModuleNotFoundError: No module named 'sklearn' and 'matplotlib'

Hey @Elijah_Nkuah,

First, Welcome to the Streamlit community!!! :partying_face: :partying_face: :partying_face: :tada:

Now let’s get down to business! :face_with_monocle:

Looking at your app you have 13 distinct packages that you import in whole or functions from them

the packages you import in your insurance_streamlit.py file are listed here

sklearn
streamlit
pandas
numpy
matplotlib
seaborn
xgboost
catboost
lightgbm
plotly
altair
base64
csv

BUT when it comes to your requirements.txt file, you have 253 specific dependancies that are being pip installed on your Streamlit Sharing app. When I say specific here, I mean they each have a version specifier (the == #.#.# part). This makes me think that you generated your pip requirements file automatically, but that you weren’t in a clean environment :question:

I think this is the main problem you’re experiencing, your requirements.txt file should ideally only have the packages you intend to use for this project. You can fix this by either:

  1. Creating a new environment on your computer and installing just the 13 packages you use in your app, and then re-generating your requirements file
  2. Creating your requirements.txt by hand by just copying in the list in the toggle above (for now let’s forget the version specifier)
Side Note: Torch Info

Also, I noticed your installing Torch (400 MB in size), our Sharing platform only allows 800 MB of space for each person’s app, which makes this a huge portion of the total space. Luckly, you are not using Torch and so I would highly recommend removing at least this requirement! :nerd_face:

Let me know if this works!
Marisa

2 Likes