Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.7K
Vistas
ModuleNotFoundError: No module named 'sklearn.externals.six'

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?

over 4 years ago · Santiago Trujillo
11 Respuestas
Responde la pregunta

0

You can use the official six package. First Install six using: pip install six and then you import the module. No need to downgrade scikit-learn.

over 4 years ago · Santiago Trujillo Denunciar

0

I'm coming late, but this is due to the mglearn package (which internally tries to import six).

You must have an old version, because their versions posted on github don't have this issue. Perhaps from a CD coming with the book...

To fix the issue do something along the lines of:
pip install --upgrade mglearn

over 4 years ago · Santiago Trujillo Denunciar

0

You can use something like below..

from six import StringIO
over 4 years ago · Santiago Trujillo Denunciar

0

Downgrade your scikit-learn version:

In jupyter notebook:

!pip install --upgrade scikit-learn==0.20.3

In terminal:

pip install --upgrade scikit-learn==0.20.3

After that, the code will recognize the sklearn.external.six module.

over 4 years ago · Santiago Trujillo Denunciar

0

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.

over 4 years ago · Santiago Trujillo Denunciar

0

It will be in pandas 0.22 module as after upgradation of version , it was removed i.e. sklearn.external.six . you can check documentation if still confused.

over 4 years ago · Santiago Trujillo Denunciar

0

ModuleNotFoundError: No module named 'sklearn.externals'; 'sklearn' is not a package

I had this error show up and tried everything here. Eventually realized that I had named a file "sklearn.py" in the directory...

over 4 years ago · Santiago Trujillo Denunciar

0

You may try this:-

import six
import sys
sys.modules['sklearn.externals.six'] = six

It worked for me.

Courtesy - https://github.com/alkaline-ml/pmdarima/issues/355

over 4 years ago · Santiago Trujillo Denunciar

0

Depending on which IDE you're using but if it is spyder then you have to add a spyder kernel as must to your python installation using the following code: pip install spyder-kernels

over 4 years ago · Santiago Trujillo Denunciar

0

Replace the header fixed for me
import six

over 4 years ago · Santiago Trujillo Denunciar

0

pip install --upgrade scikit-learn==0.20.3
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda