Skip to content
Advertisement

Unable to load pickle file in streamlit

I have some code to deploy model in streamlit. I just upload all file to github and share it in streamlit app. Here is some code

JavaScript

It runs perfect in local. But in streamlit it has some bug

JavaScript

It’s the first time that I work on streamlit. So, thank you for reading! Have a nice day!

Advertisement

Answer

I had the same issue. As I saved my model built it in scikit-learn, the pickle file depends on scikit-learn for its structure.

Additionally, I didn’t import sckilearn in the python file for the web app streamlit. Therefore, using pipreqs ./ to generate pip requirements.txt file based on imports of this project did not include sklearn.

Thus, I had to include manually it inside of requirements.txt: scikit-learn==0.24.2

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement