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)
4 Likes
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
2 Likes
No i did…and it was even present in the Requriment.txt file
1 Like
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
2 Likes
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
2 Likes
Hi @ASR373, welcome to the Streamlit community!
To fix the error, include scikit-learn
in your requirements.txt
Happy Streamlit-ing!
Snehan
2 Likes
@snehankekre just scikit-learn or I have to assign its version too??
2 Likes
@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
2 Likes
@snehankekre It worked bro thanks a lot!!!
But may I know why my pipreqs didn’t include scikit-learn in my requirements.txt??
2 Likes
Because you didn’t import it in your python files.
3 Likes
I included these in my requirement.txt and still getting error : No module named ‘sklearn’
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
@himanshu1856 You haven’t imported sklearn in your app though. Include the following:
import sklearn
1 Like
just AWESOME…awesome.Iwas almost thinking to rewrite My pickle file again…Thx very much
1 Like
I have added scikit-learn in requirements.txt but still error
here is my web app :
https://sepridrm-health-detector-py-app-jhmgcw.streamlitapp.com/
and here is my GitHub repo: GitHub - sepridrm/health-detector-py
1 Like
Hi @sepridrm, it looks like you’ve deleted the app.
When you re-create it, rename scikit_learn
to scikit-learn
in your requirements file.
1 Like
Hi ,
I am getting the same error.
ModuleNotFoundError: No module named ‘sklearn’.
Link for my Github file is :Machine_Dashboard/Deploy_Rev2.py at main · rohitmalhotra67/Machine_Dashboard · GitHub.
Please help
1 Like
Hi @Rohit_Malhotra
Where are you getting the error message, is it on your local computer or on Streamlit Cloud?
If it’s locally, make sure to have scikit-learn installed which you can do via pip install scikit-learn
If it’s on Streamlit Cloud, please make sure to include scikit-learn
or a specific version as in scikit-learn==0.23.2
inside the requirements.txt
file
2 Likes
App is running fine on local PC.This error is coming when i am trying to deploy over streamlit cloud. scikit-learn==1.1.2 is mentioned in my requirement.txt file.
Please help.
1 Like