Search code examples
pythonpickle

ModuleNotFoundError: No module named 'sklearn' while loading a model


I want to load and open a file so I can check an AI model. However, my code is throwing ModuleNotFoundError: No module named 'sklearn' even though I'm not using sklearn. Why is this happening, and how can I fix it?

My code is below:

import pickle
modell = pickle.load(open('model.pkl','rb'))

Solution

  • The model you are trying to load obviously uses sklearn. This makes sense when you are trying to load a machine learning model, as sklearn is a really popular library.

    Install sklearn with pip install scikit-learn