I pickled a model on Kaggle and tried to download it to run locally. Using poetry and pyenv I ran the following commands to create a project:
pyenv local 3.6.6
poetry new model_api
cd model_test
poetry env use python
poetry add "sklearn>=0.21.3"
but received the error below.
If I simply use sklearn and install it with poetry I get this error when executing my code in VS Code.
/bin/python /home/gary/Documents/model_api/model_api/app.py
Traceback (most recent call last):
File "/home/gary/Documents/model_api/model_api/app.py", line 5, in <module>
model = pickle.load(f)
ModuleNotFoundError: No module named 'sklearn.ensemble.forest'
This is the code I am attempting to run.
import sklearn
import pickle
f = open('./model/ForestModel','rb')
model = pickle.load(f)
I'm trying to use Python 3.6.6 and sklearn 0.21.3 based on what I'm seeing on Kaggle:
If I try to use a more current version of Python like 3.8.10 I get the same error. I think I'm missing something simple/obvious. Any pointers or things I could check would be greatly appreciated.
There is no package sklearn
with the version you like to be installed. I think you are looking for scikit-learn
instead (Docs).
You can install the most up to date version that is supported by your other dependencies by running:
poetry add scikit-learn
Or if you need to install a specific version:
poetry add "scikit-learn==0.24.2"
For other options, check out the poetry docs here.