Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.7K
Views
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 answers
Answer question

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 Report

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 Report

0

You can use something like below..

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

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 Report

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 Report

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 Report

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 Report

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 Report

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 Report

0

Replace the header fixed for me
import six

over 4 years ago · Santiago Trujillo Report

0

pip install --upgrade scikit-learn==0.20.3
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!