'Cannot import Sklearn from sklearn.externals.joblib

I am a beginner and I just started with machine learning. I am trying to import classes like imputer from sklearn but i am unable to do it.

from sklearn.preprocessing import Imputer,LabelEncoder,OneHotEncoder,StandardScaler

ImportError: cannot import name 'version' from 'sklearn.externals.joblib' (C:\ProgramData\Anaconda3\lib\site-packages\sklearn\externals\joblib__init__.py)



Solution 1:[1]

I had the same problem. I have replaced

from sklearn.externals import joblib

with

import joblib

and it works fine in Python 3.7.2

Solution 2:[2]

I believe there was an update on Scikit-learn that render that import unusable.

I had my local installation to be version 0.20.3 and this import is pefectly working. But on my server I have installation 0.23.1 and this error pop up. Something must be chaging in the new version.

For my case, use import joblib fix the problem. In your case it seems more complicated. This sounds very much likeky to be caused if you have more than one Scikit-learn version installed on your system. You need to uninstall all of them and do a clean install of sklearn.

Solution 3:[3]

The problem sometimes happens due to the version. This may help: If you has written like this

from sklearn.externals import joblib

Modify it as this:

import joblib

Solution 4:[4]

Try python -m pip install sklearn --upgrade and python -m pip install joblib --upgrade

and then, use this : import joblib

Good luck.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kate Orlova
Solution 2
Solution 3 Suat Atan PhD
Solution 4 Lingxiao