Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 819
Fred Cozzi Avatar asked May 19 '20 21:05

Fred Cozzi


People also ask

How do you fix ModuleNotFoundError No module named Sklearn?

The Python "ModuleNotFoundError: No module named 'sklearn'" occurs when we forget to install the scikit-learn module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install scikit-learn command.

Why Sklearn is not working?

Every time you install a package, this installation is associated with just a single version. Therefore, there's a chance that you have installed scikit-learn for one Python version, but you are executing your source code using a different version and this may be the reason why scikit-learn cannot be found.

How do you solve no modules named Sklearn externals 6?

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.


2 Answers

You can use something like below..

from six import StringIO 
like image 157
Mamun Or Rashid Avatar answered Sep 21 '22 18:09

Mamun Or Rashid


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.

like image 35
Ramesh Shah Avatar answered Sep 19 '22 18:09

Ramesh Shah