5

I'm using Python 3, and trying to use joblib. I have the following I am trying to import:

import sklearn.externals as extjoblib
import joblib

I receive the error: ModuleNotFoundError: No module named 'sklearn.externals.joblib'

I try to use pip3 install sklearn.external --user but have had no luck. Could someone help me install this?

greendaysbomb
  • 364
  • 2
  • 6
  • 23
  • 1
    Hi, I think that module has been deprecated [see this](https://github.com/skekre98/NBA-Search/issues/19) – bench Oct 24 '20 at 04:33
  • Does this answer your question? [ModuleNotFoundError: No module named 'sklearn.utils.\_joblib'](https://stackoverflow.com/questions/54965751/modulenotfounderror-no-module-named-sklearn-utils-joblib) – felice Oct 24 '20 at 19:49

3 Answers3

19

I got the same ModuleNotFoundError but in another context, while trying to import a library, and found this workaround useful:

import joblib

sys.modules['sklearn.externals.joblib'] = joblib

The reason being that sklearn.externals does not have a joblib module, at least in my version, so I normally import the joblib package and then tell sklearn.externals where to find by using sys.modules.

Once I did that, I found that the error disappeared when I imported the library again.

CharlieNeutron
  • 188
  • 1
  • 6
4

since scikit-learn version 0.23, the package joblib is deprecated from sklearn, you can just import joblib individually.

import joblib

That's it.

wow_fan
  • 111
  • 1
  • 10
3

I just wrote

import joblib

instead of both

import sklearn.external.joblib as joblib
import joblib

This worked for me.