Fail to load model and encoder

Hello everyone,

This is my first time using Streamlit, and I encountered some errors.

I’m quite new to data science and Python, so I’d really appreciate it if you could take a look at my code.

I built the model in the same environment where I’m running the app.

GitHub Repository:

Errors:
:x: Error loading model models/self made/one_hot_encoder.pkl: 0
:white_check_mark: Model loaded: models/self made/scaler3.pkl
:x: Error loading model models/catboost_model.pkl: No module named ‘catboost’

Any help would be greatly appreciated! :rocket:

Welcome. One of the best practices in streamlit app development that we need to also learn is managing our app’s dependencies. A very important file called requirements.txt is needed. On this file we need to write all the libraries that your app will be using.

Example:

requirements.txt
streamlit
catboost

You can write there all the other libraries that you may need.

One the errors that you posted:

No module named ‘catboost’

is due to the missing catboost library. This has to be installed.

You can place your requirements.txt file on the same location as your main streamlit file.

To install it locally just send the following in the terminal.

pip install -r requirements.txt

When you deploy your app in community cloud later for example, you don’t need to do anything. As long as you have the requirements.txt file, the cloud will take care of your apps’ dependencies.