greendaysbomb
greendaysbomb

Reputation: 404

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

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?

Upvotes: 7

Views: 32142

Answers (3)

wow_fan
wow_fan

Reputation: 125

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

import joblib

That's it.

Upvotes: 5

CharlieNeutron
CharlieNeutron

Reputation: 218

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.

Upvotes: 21

user8917421
user8917421

Reputation:

I just wrote

import joblib

instead of both

import sklearn.external.joblib as joblib
import joblib

This worked for me.

Upvotes: 4

Related Questions