No module named 'sklearn'

ModuleNotFoundError: No module named ‘sklearn’

Traceback:

File "/usr/local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)

File “/app/ml_deploy_using_streamlit/app.py”, line 7, in
classifier = pickle.load(pickle_in)

You haven’t installed sklearn on your workspace…you can use pip for that

You cal also refer to macos - ImportError: No module named sklearn (Python) - Stack Overflow

1 Like

No i did…and it was even present in the Requriment.txt file

Hey @Pratap517!

Thanks for popping your question on our forum! Can you post the link to your github repo that your deploying your Sharing app from? I can then checkout your requirements file see if there’s anything funny happening!

also, this post might be helpful:

Cheers,
Marisa

Hey @Marisa_Smith,

  Adith here, I too face the same error. i.e, 

ModuleNotFoundError: No module named ‘sklearn’

here is my web app: https://share.streamlit.io/asr373/diabetes-risk-prediction-app/app.py

and here is my GitHub repo: GitHub - ASR373/diabetes-risk-prediction-app

1 Like

Hi @ASR373, welcome to the Streamlit community! :tada: :wave:

To fix the error, include scikit-learn in your requirements.txt :wink:

Happy Streamlit-ing! :balloon:
Snehan

1 Like

@snehankekre just scikit-learn or I have to assign its version too??

1 Like

@ASR373 Just scikit-learn should work:

numpy==1.20.1
streamlit==0.76.0
seaborn==0.11.1
matplotlib==3.4.1
plotly==4.14.3
pandas==1.2.3
joblib==0.16.0
scikit-learn
1 Like

@snehankekre It worked bro thanks a lot!!!

But may I know why my pipreqs didn’t include scikit-learn in my requirements.txt??

1 Like

Because you didn’t import it in your python files.

2 Likes