cannot import name 'haversine_distances' from 'sklearn.metrics.pairwise'

Viewed 1943

import pysal as ps

I'm tring to import pysal but I get the following:

cannot import name 'haversine_distances' from 'sklearn.metrics.pairwise'

So I tried: from sklearn.metrics.pairwise import haversine_distances

and I get the same message. Any suggestions?

2 Answers

The problem may be that your version of scikit-learn is out of date. Try uninstalling and reinstalling scikit-learn from the terminal like so:

conda uninstall scikit-learn

Confirm, and wait for the packages to be uninstalled. Then, do conda install scikit-learn and conda install pysal to reinstall the packages. You'll also need to reinstall any other packages that rely on scikit-learn as well.

I had the same issue, and this fixed the problem for me.

Related