'Import error _euclidean_distances from sklearn.metrics.pairwise
I am working with Orange 3.30.1 trying to use the Python Script widget to add SMOTE to my data classification problem (the Orange team has refrained from implementing it, and suggest this way instead: https://github.com/biolab/orange3/pull/3269).
To be able to move on, I installed the imblearn library using the Orange Command Prompt with pip since it does not come with Orange:
(C:\Users\name\AppData\Local\Programs\Orange) C:\Users\name\AppData\Local\Programs\Orange>pip install imblearn
Collecting imblearn
Using cached imblearn-0.0-py2.py3-none-any.whl (1.9 kB)
Collecting imbalanced-learn
Using cached imbalanced_learn-0.8.1-py3-none-any.whl (189 kB)
Requirement already satisfied: numpy>=1.13.3 in c:\users\name\appdata\local\programs\orange\lib\site-packages (from imbalanced-learn->imblearn) (1.21.2)
Requirement already satisfied: scikit-learn>=0.24 in c:\users\name\appdata\local\programs\orange\lib\site-packages (from imbalanced-learn->imblearn) (1.0)
Requirement already satisfied: scipy>=0.19.1 in c:\users\name\appdata\local\programs\orange\lib\site-packages (from imbalanced-learn->imblearn) (1.5.3)
Requirement already satisfied: joblib>=0.11 in c:\users\name\appdata\local\programs\orange\lib\site-packages (from imbalanced-learn->imblearn) (1.0.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\name\appdata\local\programs\orange\lib\site-packages (from scikit-learn>=0.24->imbalanced-learn->imblearn) (2.2.0)
Installing collected packages: imbalanced-learn, imblearn
Successfully installed imbalanced-learn-0.8.1 imblearn-0.0
But this import line of the Python code pasted into the widget:
from imblearn.over_sampling import SMOTE
results in an import error:
ImportError: cannot import name '_euclidean_distances' from 'sklearn.metrics.pairwise' (C:\Users\name\AppData\Local\Programs\Orange\lib\site-packages\sklearn\metrics\pairwise.py)
>>>
I have checked that the file sklearn.metrics.pairwise
and the corresponding function _euclidean_distances
are really there. A direct manual import of the same function results in the same error. But a manual report of the associated function euclidean_distances
in the same file does not raise an import error.
Anyone who has experienced the same kind of problem?
Solution 1:[1]
I also faced the same error and mine got resolved by updating all my libraries using: conda update conda
Solution 2:[2]
after installing the imblearn library, try saving the Jupiter notebook and executing it again or by opening a new IPython console
Solution 3:[3]
Well, I got same error. I saw that, some libraries can't import by py. file, so I followed the error massage and I changed these libraries by manuel. If you do same thing like me, you just should do a few changes in cluster.py and agglomerative.py
Solution 4:[4]
Few have faced this problem and it was resolved by Reinstalling scipy and restarting the python shell.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tushar Tyagi |
Solution 2 | Utkarsh Surwade |
Solution 3 | o?uzhan Akkurt |
Solution 4 | Archana David |