Ayush Bajpayee
Ayush Bajpayee

Reputation: 71

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)

Upvotes: 7

Views: 24915

Answers (5)

Francis Ezeani
Francis Ezeani

Reputation: 1

import joblib

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

Upvotes: -1

Suat Atan PhD
Suat Atan PhD

Reputation: 1382

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

Upvotes: 0

Konstantinos Kotsis
Konstantinos Kotsis

Reputation: 161

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

Upvotes: 15

Tamaki Sakura
Tamaki Sakura

Reputation: 519

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.

Upvotes: 6

Lingxiao
Lingxiao

Reputation: 9

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

and then, use this : import joblib

Good luck.

Upvotes: -1

Related Questions