7

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)

sentence
  • 8,213
  • 4
  • 31
  • 40
Ayush Bajpayee
  • 71
  • 1
  • 1
  • 2
  • The first idea would be to check that sklearn and joblib are both installed and up to date. Try `python -m pip install sklearn --upgrade` and `python -m pip install joblib --upgrade`. Can you provide a full error report? – Ashargin May 13 '19 at 14:00

5 Answers5

15

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

Kate Orlova
  • 3,225
  • 5
  • 11
  • 35
6

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.

Tamaki Sakura
  • 482
  • 5
  • 22
0

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
Suat Atan PhD
  • 1,152
  • 13
  • 27
-1

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

and then, use this : import joblib

Good luck.

-1
import joblib

This works for me. Actually I was having that kinda challenge

Hadar
  • 658
  • 4
  • 17