I wanna install smote from imblearn package and I got the Following error:

ImportError                               Traceback (most recent call last)
<ipython-input-10-77606507c62c> in <module>()
     66 len(data[data["num"]==0])
     67 #balancing dataset
---> 68 from imblearn.over_sampling import SMOTE
     69 import matplotlib.pyplot as plt
     70 sm = SMOTE(random_state=42)

~\Anaconda3\lib\site-packages\imblearn\__init__.py in <module>()
     33 """
---> 35 from .base import FunctionSampler
     36 from ._version import __version__

~\Anaconda3\lib\site-packages\imblearn\base.py in <module>()
     17 from sklearn.utils import check_X_y
---> 19 from .utils import check_sampling_strategy, check_target_type
     20 from .utils.deprecation import deprecate_parameter

~\Anaconda3\lib\site-packages\imblearn\utils\__init__.py in <module>()
      5 from ._docstring import Substitution
----> 7 from ._validation import check_neighbors_object
      8 from ._validation import check_target_type
      9 from ._validation import check_ratio

~\Anaconda3\lib\site-packages\imblearn\utils\_validation.py in <module>()
     13 from sklearn.base import clone
---> 14 from sklearn.neighbors.base import KNeighborsMixin
     15 from sklearn.neighbors import NearestNeighbors
     16 from sklearn.externals import six

~\Anaconda3\lib\site-packages\sklearn\neighbors\__init__.py in <module>()
      7 from .kd_tree import KDTree
      8 from .dist_metrics import DistanceMetric
----> 9 from .graph import kneighbors_graph, radius_neighbors_graph
     10 from .unsupervised import NearestNeighbors
     11 from .classification import KNeighborsClassifier, RadiusNeighborsClassifier

~\Anaconda3\lib\site-packages\sklearn\neighbors\graph.py in <module>()
      5 # License: BSD 3 clause (C) INRIA, University of Amsterdam
----> 7 from .base import KNeighborsMixin, RadiusNeighborsMixin
      8 from .unsupervised import NearestNeighbors

~\Anaconda3\lib\site-packages\sklearn\neighbors\base.py in <module>()
     20 from .kd_tree import KDTree
     21 from ..base import BaseEstimator
---> 22 from ..metrics import pairwise_distances_chunked
     23 from ..metrics.pairwise import PAIRWISE_DISTANCE_FUNCTIONS
     24 from ..utils import check_X_y, check_array, gen_even_slices

ImportError: cannot import name 'pairwise_distances_chunked' from 'sklearn.metrics' (C:\Users\ASUS\Anaconda3\lib\site-packages\sklearn\metrics\__init__.py)

3 Answers 3


Try quitting and restarting ipython. imblearn requires scikit-learn >= 0.20 and sometimes the ipython runtime loads an older version of scikit-learn.

If the issue still persists, then reinstall all packages together to make sure they are compatible with each other.

  • $\begingroup$ I was getting a different import error with SMOTE and this worked for that as well. $\endgroup$ Apr 6, 2020 at 12:27

You can use:

conda install -c conda-forge imbalanced-learn

to reinstall it. This solved my problem.

pip install Tensorflow


pip install imblearn 

After the installation restart the system, as The imblearn.tensorflow provides utilities to deal with imbalanced dataset in tensorflow, and imblearn uses Tensorflow as backend.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.