1

I have a random forest model that I am building in a pipeline that uses scikit-learn v0.23.1. Once the model is built I am downloading it and trying to locally load it using model = joblib.load("model_name.joblib").

However, when I try to do this I get the error:

File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 587, in load
    obj = _unpickle(fobj, filename, mmap_mode)
  File "/usr/local/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 506, in _unpickle
    obj = unpickler.load()
  File "/usr/local/Cellar/python@3.7/3.7.9_3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py", line 1088, in load
    dispatch[key[0]](self)
  File "/usr/local/Cellar/python@3.7/3.7.9_3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py", line 1385, in load_stack_global
    self.append(self.find_class(module, name))
  File "/usr/local/Cellar/python@3.7/3.7.9_3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py", line 1426, in find_class
    __import__(module, level=0)
ModuleNotFoundError: No module named 'scipy.sparse._csr'

I have done this process fine for a while and only recently it has started to get the above error.

Daniel Wyatt
  • 960
  • 1
  • 10
  • 29
  • does `pip list` shows the package `scipy`? if yes, i would try re-installing `scipy`. `pip uninstall scipy pip install scipy` – simpleApp Feb 09 '22 at 14:47
  • 2
    So I managed to solve it. The pipeline was building the model using python 3.8 and I was loading it locally using python 3.7. Not sure why that stopped working recently but switching locally to 3.8 meant that it worked. – Daniel Wyatt Feb 09 '22 at 15:38

0 Answers0