如何从python(ModuleNotFoundError)运行scikitlearn版本为0.24的“spherecluster”包?

2024-06-25 22:43:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要从https://github.com/jasonlaska/spherecluster导入模块“spherecluster”。(python/pipy) 但它不适用于最新版本的scikit学习包版本>;0.24 .

我得到以下错误:

ModuleNotFoundError: No module named 'sklearn.cluster.k_means_'

我发现k_means_在未来的版本中被重命名。(代码结构已更改)

如何解决这个问题

我是否需要完全重写spherecluster中的代码以使用当前的sklearn版本运行


Tags: 模块代码httpsgt版本githubcom错误
1条回答
网友
1楼 · 发布于 2024-06-25 22:43:49

This is an open issue on the package,从作者缺乏反应来看,似乎被忽视了。继续骚扰他们,表达你对公关的支持

否则,正确的解决方案是将Conda环境限制为仅使用兼容版本的scikit learn

## create a new env with the constraint
conda create -n spherecluster python=3.7 pip scikit-learn=0.22

## activate it
conda activate spherecluster

## install the package from 
pip install spherecluster

不太合适的解决方案是从PR分支安装spherecluster包:

conda activate your_env
pip install git+https://github.com/rfayat/spherecluster.git@scikit_update

相关问题 更多 >