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

Fred Cozzi picture Fred Cozzi · May 19, 2020 · Viewed 25.6k times · Source

I keep getting the error

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

when running the code below:

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import pandas as pd
import mglearn
import numpy as np
from IPython.display import display
import matplotlib as pl
import sklearn

iris_dataset = load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris_dataset['data'], iris_dataset['target'], random_state=0)
iris_dataframe = pd.DataFrame(X_train, columns=iris_dataset.feature_names)
pd.plotting.scatter_matrix(iris_dataframe, c=y_train, figsize=(15, 15), marker='o', hist_kwds={'bins':20}, s=60, alpha=.8, cmap=mglearn.cm3)

Is there a module I haven't imported or installed?

Answer

jv95 picture jv95 · May 20, 2020

module sklearn.externals.six was removed in version 0.23. if you want to use this module, you have to downgrade to version 0.22 or lower.