繁体   English   中英

导入错误:无法导入名称“distribute_covar_matrix_to_match_covariance_type”

[英]ImportError: cannot import name 'distribute_covar_matrix_to_match_covariance_type'

我正在尝试运行hmmlearn 教程中的代码,但从已删除的方法“distribute_covar_matrix_to_match_covariance_type”中收到导入错误。 我不知道如何在 Anaconda 中安装不会导致此问题的 hmmlearn 版本。

我在 Windows 10 上运行它:

  • (名称、版本、版本、频道)
  • hmmlearn,0.3.0b,np112py36_0,omnia
  • scikit-learn,0.20.1,py36hb854c30_0
  • 蟒蛇,3.6.8,h9f7ef89_7

我已经使用以下命令通过 Anaconda 安装了 hmmlearn 和 scikit-learn: conda install -c omnia hmmlearn

在我看来,通过 Anaconda 安装的 hmmlearn 不是 hmmlearn 的最新版本,因为在文件hmm.py这一行from sklearn.mixture import ( distribute_covar_matrix_to_match_covariance_type, _validate_covars ) 对比最新版的hmmlearn

在 Anaconda 中与 hmmlearn 一起安装的捆绑 scikit-learn 中, distribute_covar_matrix_to_match_covariance_type方法被删除,因为它应该在 scikit-learn 0.20.1 中。 它在 0.20 中被移除

from hmmlearn import hmm
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-19-16c29f744bfe> in <module>
----> 1 from hmmlearn import hmm

~\Documents\Anaconda\lib\site-packages\hmmlearn\hmm.py in <module>
     14 from scipy.misc import logsumexp
     15 from sklearn import cluster
---> 16 from sklearn.mixture import (
     17     distribute_covar_matrix_to_match_covariance_type, _validate_covars
     18 )

ImportError: cannot import name 'distribute_covar_matrix_to_match_covariance_type'

问题似乎是 Anaconda 正在安装不兼容的 hmmlearn 和 scikit-learn 版本。 关于如何安装这些软件包的兼容版本的任何建议?

从@Vivek Kumar 运行 conda conda install -c conda-forge hmmlearn

如果这不起作用,请删除 hmmlearn

conda remove hmmlearn

然后用pip重新安装

pip install --upgrade --user hmmlearn

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM