Cannot run 'sklearn'

Hi, I was trying to deploy a webapp through streamlit and came across with following error

Traceback :

  File "/app/mlwebapp/webapp.py", line 5, in <module>
    from sklearn.metrics import accuracy_score
ModuleNotFoundError: No module named 'sklearn

I would like to ask if there is any way to handle this error

(PS, the github repo for this project is : GitHub - Bruce95317/MLwebapp)

Thank you for your time

I suspect that already the deployment of the requirements fails, are there any error messages there?
Then I also notice that your requirements.txt is quite long, do you really need all the libs? I guess not.

Edit:
I assume that for example pywin32 may fail to deploy on streamlit sharing.
This would possibly explain that pandas but not sklearn can be imported.
Therefore please declutter your requirements.txt file…

 Downloading pytz-2020.5-py2.py3-none-any.whl (510 kB)
ERROR: Could not find a version that satisfies the requirement pywin32==300
ERROR: No matching distribution found for pywin32==300
[manager] Python dependencies were installed from requirements.txt using pip.
[manager] Processed dependencies!
2021-04-06 16:53:49.562 An update to the [server] config option section was detected. To have these changes be reflected, please restart streamlit.
2021-04-06 16:53:49.643 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 333, in _run_script
    exec(code, module.__dict__)
  File "/app/mlwebapp/webapp.py", line 5, in <module>
    from sklearn.metrics import accuracy_score
ModuleNotFoundError: No module named 'sklearn'

this was the log I saw during this error

My guess was right :wink:
Streamlit Sharing is not Windows, so it doesn’t work.
So please clean up!

1 Like

Thank you, i will have a go with it and see if this works

this worked. Thank you