I have the following error, could you please help me with the solution?

2022-12-28 08:24:39.298 Uncaught app exception
Traceback (most recent call last):
File “C:\Users\Bruno\anaconda3\lib\site-packages\streamlit\runtime\scriptrunner\”, line 565, in _run_script
exec(code, module.dict)
File “C:\Users\Bruno\maintenance_app\”, line 29, in
modelo = load(‘classifier_binary.pkl’)
File “C:\Users\Bruno\anaconda3\lib\site-packages\joblib\”, line 587, in load
obj = _unpickle(fobj, filename, mmap_mode)
File “C:\Users\Bruno\anaconda3\lib\site-packages\joblib\”, line 506, in _unpickle
obj = unpickler.load()
File “C:\Users\Bruno\anaconda3\lib\”, line 1212, in load
KeyError: 0

Hey @Bruno_A,

Welcome to our forum! :balloon:

When sharing code problems in the forum, please make sure to share a minimal context so we can understand what’s going on :slight_smile: for instance, source code and what python/streamlit versions you’re using.

That being said, it seems like the error is coming from loading your pickled classifier, and that has no link with the streamlit library. Did a quick search and found that this may be a common issue when mistakenly using import joblib instead of from sklearn.externals import joblib. See this SO thread.


I solved the problem. The error is related to the machine learning models not being installed on the terminals. Thanks for the feedback.

1 Like


I tried all the best possible options still getting below error. Please advise.

Welcome to the Streamlit forum! :wave:

The issue is unrelated to Streamlit, please look through past forum threads on this topic and also consult the SO thread shared above: python - KeyError when loading pickled scikit-learn model using joblib - Stack Overflow

We try limiting posts on the Streamlit forum to Streamlit-specific issues. Additionally, please avoid tagging or DM’ing Streamlit staff and moderators.

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