Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.7K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

0

You can use something like below..

from six import StringIO
over 4 years ago · Santiago Trujillo Relatório

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 Relatório

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 Relatório

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 Relatório

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 Relatório

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 Relatório

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 Relatório

0

Replace the header fixed for me
import six

over 4 years ago · Santiago Trujillo Relatório

0

pip install --upgrade scikit-learn==0.20.3
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda