簡體   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