ModuleNotFoundError: No module named 'sklearn.externals.joblib'

Viewed 18799

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?

3 Answers

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.

I just wrote

import joblib

instead of both

import sklearn.external.joblib as joblib
import joblib

This worked for me.

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

import joblib

That's it.

Related