question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name '_k_means'

See original GitHub issue

Hi. I install spherecluster usingpip install spherecluster successfully in Ubuntu 18.04. But when I call from spherecluster import SphericalKMeans, I got an ImportError.

Traceback (most recent call last):
  File "LM/vectors_cluster.py", line 9, in <module>
    from spherecluster import SphericalKMeans
  File "/path_to_anaconda/lib/python3.6/site-packages/spherecluster/__init__.py", line 2, in <module>
    from .spherical_kmeans import SphericalKMeans
  File "/path_to_anaconda/lib/python3.6/site-packages/spherecluster/spherical_kmeans.py", line 16, in <module>
    from sklearn.cluster import _k_means
ImportError: cannot import name '_k_means'

Here is my environmental information:

Package Version
numpy 1.14.3
scipy 1.1.0
scikit-learn 0.22.2.post1
pytest 3.5.1
nose 1.3.7
joblib 0.14.1
spherecluster 0.1.7

If anyone can help me, I would really appreciate it!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

3reactions
YBZhcommented, Apr 2, 2020

It seems that downgrading the sklearn to the older version of 0.20.0 can solve the problem. conda install scikit-learn=0.20.0

2reactions
glicericocommented, Apr 29, 2020

This is a workaround, not a solution. A side-effect of downgrading to 0.20.0 is that the OPTICS clustering algorithm is not available anymore. Can we re-open this issue, and find a proper solution for it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

importing KMeans from sklearn.cluster throws error #18841
Describe the bug. For some reason, I cannot import Kmeans from sklearn. cluster. However, importing other classes from sklearn.
Read more >
Import error. Can't import kmeans_plusplus - Stack Overflow
According to the documentation, kmeans_plusplus is. New in version 0.24. so it is not available for the version 0.23.2 you are using.
Read more >
No module named sklearn.cluster, Parameters extraction not ...
ImportError : No module named sklearn.cluster, Parameters extraction not yet performed! ... from ductape.phenome.clustering import mean, kmeans, plotClusters
Read more >
Fix ModuleNotFoundError: No module named 'sklearn'
This error indicates that the scikit-learn (aka sklearn ) package was not installed, or even if it was installed for some reason it...
Read more >
PYTHON : ImportError in importing from sklearn - YouTube
PYTHON : ImportError in importing from sklearn: cannot import name check_build [ Gift : Animated Search Engine ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found