Python code works fine when run in computer but does not when pushed to streamlit

I have an ML model that was saved as a pickle in the local computer “model.pkl”
However, when I try to apply this model on new data, it gives me the error:
XGBoostError: [13:38:10] C:\Users\Administrator\workspace\xgboost-win64_release_1.1.0\include\xgboost/json.h:65: Invalid cast, from Null to Array

Doest anyone know what could be the problem?

You cannot access files on your local computer when running on streamlit cloud.

I tried also by putting everything on github, my code and the model. I load my model like this:
model_from_joblib = joblib.load(‘default_class_model.pkl’)
Where ‘default_class_model.pkl’ is also inside my Github repository. I get the same error. Is this having to do with how I am loading ‘default_class_model.json’? how should I load it otherwise?

I can only guess…
Probably you are using too old xgboost version (1.1.0) , since support for JSON was introduced in xgboost version 1.3
Can you share your github repo link?

Hi Franky,

I checked and I trained my model is in the latest xgboost version. I also made sure to deploy the app on the latest python version 3.9 (although my model is trained on 3.10 )

FYI the code does not contain the training part

But in your requirements.txt file you have in general quite old library versions, for example:


You were right! Thank you so much!

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