Cannot import 'DistanceMetric' from 'sklearn.metrics'

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/24302

<div type='discussions-op-text'>

<sup>Originally posted by **anubhavde** August 30, 2022</sup>
# **ImportError: cannot import name 'DistanceMetric' from 'sklearn.metrics' (/home/linux/miniconda3/envs/python_ai/lib/python3.8/site-packages/sklearn/metrics/__init__.py)**

I know **DistanceMetric** can be found in ```sklearn.neighbors``` and not ```sklearn.metrics``` but I still recieve an ImportError. How do I solve this issue?

### **How to reproduce the Error:**
I am trying to run the following code 
```python
import gc, itertools
import scipy as sp 
import numpy as np 
from tqdm.auto import tqdm

import warnings
warnings.filterwarnings("ignore")

import pandas as pd
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)

from sklearn.preprocessing import StandardScaler, OrdinalEncoder, MinMaxScaler
from sklearn.metrics import roc_auc_score, roc_curve
from sklearn.neighbors import DistanceMetric as _DistanceMetric
from imblearn.over_sampling import SMOTE
```

### **Error Message:**
```
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/home/linux/Workspace/tabular-playground-series-aug-2022/submission.ipynb Cell 3 in <cell line: 16>()
     [14](vscode-notebook-cell:/home/linux/Workspace/tabular-playground-series-aug-2022/submission.ipynb#W0sZmlsZQ%3D%3D?line=13) from sklearn.preprocessing import StandardScaler, OrdinalEncoder, MinMaxScaler
     [15](vscode-notebook-cell:/home/linux/Workspace/tabular-playground-series-aug-2022/submission.ipynb#W0sZmlsZQ%3D%3D?line=14) from sklearn.metrics import roc_auc_score, roc_curve
---> [16](vscode-notebook-cell:/home/linux/Workspace/tabular-playground-series-aug-2022/submission.ipynb#W0sZmlsZQ%3D%3D?line=15) from sklearn.neighbors import DistanceMetric as _DistanceMetric
     [17](vscode-notebook-cell:/home/linux/Workspace/tabular-playground-series-aug-2022/submission.ipynb#W0sZmlsZQ%3D%3D?line=16) from imblearn.over_sampling import SMOTE

File ~/miniconda3/envs/python_ai/lib/python3.8/site-packages/sklearn/neighbors/__init__.py:8, in <module>
      6 from ._ball_tree import BallTree
      7 from ._kd_tree import KDTree
----> 8 from ._distance_metric import DistanceMetric
      9 from ._graph import kneighbors_graph, radius_neighbors_graph
     10 from ._graph import KNeighborsTransformer, RadiusNeighborsTransformer

File ~/miniconda3/envs/python_ai/lib/python3.8/site-packages/sklearn/neighbors/_distance_metric.py:4, in <module>
      1 # TODO: Remove this file in 1.3
      2 import warnings
----> 4 from ..metrics import DistanceMetric as _DistanceMetric
      7 class DistanceMetric(_DistanceMetric):
      8     @classmethod
      9     def _warn(cls):

ImportError: cannot import name 'DistanceMetric' from 'sklearn.metrics' (/home/linux/miniconda3/envs/python_ai/lib/python3.8/site-packages/sklearn/metrics/__init__.py)
```

### **System/Environment Details**
OS: Manjaro Linux x86_64 
Kernel: 5.15.60-1-MANJARO 
Scikit-learn: 1.1.2
</div>

COMMENT:
Uhm it does not make sense to me (apart from if something went wrong during the installation).

Can you check if you have the file: `/home/linux/miniconda3/envs/python_ai/lib/python3.8/site-packages/sklearn/metrics/_dist_metrics.pxd`?

And what is the output of:

```bash
cat /home/linux/miniconda3/envs/python_ai/lib/python3.8/site-packages/sklearn/metrics/_dist_metrics.pxd | grep DistanceMetric
```

If the file exists and the grep shows something like

```bash
> cat _dist_metrics.pxd | grep DistanceMetric
# DistanceMetric base class
cdef class DistanceMetric:
    cdef DistanceMetric distance_metric
```

Then, I assume that the `so` file might be wrong and I would just try to uninstall and reinstall scikit-learn.

Labels: Needs Triage