Am having the following error and have try to solve it but still not solved and now i need help

ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

Traceback:

File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)File "/mount/src/heath_case_prediction/streamlit_app.py", line 8, in <module>
    model = pickle.load(open(model_path, 'rb'))

Hi @ojo_Abiodun_Joseph

The ModuleNotFoundError is typically encountered when the deployed app is missing dependent libraries. To solve this, you can add libraries used by the app (the import statements in your app.py file) in the requirements.txt file.

Hope this helps!

for the app.py file, this are what are imported
import pickle
import streamlit as st
import numpy as np
import os
but for the requirement file i only have
numpy==1.24.2
streamlit==1.18.1

what is your advice

It does seem that the prerequisite apps are:

streamlit
numpy

The error may be due to another cause, can you go to the app’s log by clicking on the “Manage app” > “…” > “Download log”

The log may shed light on the cause of the error.

this is the message that is coming up

2024-01-20 19:30:10.049 503 GET /script-health-check (10.13.124.206) 229.25ms
2024-01-20 19:30:14.762 Uncaught app exception
Traceback (most recent call last):
  File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/mount/src/heath_case_prediction/streamlit_app.py", line 8, in <module>
    model = pickle.load(open(model_path, 'rb'))
ModuleNotFoundError: No module named 'sklearn'

now working,
thanks much

Glad to hear that it is working now!

I suspect that the pickled file of the model:

is an ML model built using Scikit-learn and thus it would require scikit-learn to be added to requirements.txt file along with the corresponding import statement.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.