Skip to content
Home » ModuleNotFoundError: No module named ‘imblearn’

ModuleNotFoundError: No module named ‘imblearn’

To solve ModuleNotFoundError: No module named ‘imblearn’ error follow below methods.

Code :

from imblearn import under_sampling, over_sampling
from imblearn.over_sampling import SMOTE

ERROR LOG : When running the above code the below error occurs.

ModuleNotFoundError: No module named 'imblearn'

How to solve ModuleNotFoundError: No module named ‘imblearn’ ?

This issue ModuleNotFoundError: No module named ‘imblearn’ generally occurs when the Module named imblearn is absent. You can install the module named imblearn using anaconda command prompt by running the below command.

conda install -c conda-forge imbalanced-learn

Then imported the packages

from imblearn import under_sampling, over_sampling
from imblearn.over_sampling import SMOTE

Fix ModuleNotFoundError: No module named ‘imblearn’ using pip

You can also install the module named imblearn using anaconda command prompt by running the below command.

pip install -U imbalanced-learn

Hope the above solution works.

Also read :

AttributeError: ‘SMOTE’ object has no attribute ‘fit_sample’
AttributeError: ‘SMOTE’ object has no attribute ‘_validate_data’