簡體   English   中英

沒有名為 pyLDAvis 的模塊

[英]No module named pyLDAvis

我無法導入 pyLDAvis。

它已安裝,但由於某種原因,我無法導入它。

我試過了

conda update anaconda

pip install --upgrade pip

pip install --upgrade jupyter notebook

pip install pyLDAvis

安裝 pyLDAvis 會返回消息“要求已滿足”。 所以我嘗試卸載並重新安裝 package 但仍然無法正常工作。 任何其他軟件包都不會發生這種情況。

我怎么解決這個問題?

pyLDAvis gensim 名稱已更改。 當我使用gensim_models而不是gensim時,交互式即可以工作。

'gensim_models' 名稱在bmabey 的 repo的最新提交中。

import pyLDAvis
import pyLDAvis.gensim_models as gensimvis
pyLDAvis.enable_notebook()

# feed the LDA model into the pyLDAvis instance
lda_viz = gensimvis.prepare(ldamodel, corpus, dictionary)

以下代碼對我有用,我正在使用 Google Colaboratory。

!pip install pyLDAvis

import pyLDAvis
import pyLDAvis.gensim_models

pyLDAvis.enable_notebook()
vis = pyLDAvis.gensim_models.prepare(ldamodel, doc_term_matrix, dictionary)
vis

如果您正在使用 jupyter notebook (python vs3.3.0)

“名為 'pyLDAvis.gensim' 的 No 模塊”

可以使用以下方法解決錯誤:

import pyLDAvis.gensim_models

代替:

import pyLDAvis.gensim

請按照以下

import pyLDAvis.gensim_models as gensimvis
pyLDAvis.enable_notebook()
vis = gensimvis.prepare(lda_model, corpus, dictionary)
vis

即使在查看了您的答案之后,

我將代碼修改為

import pyLDAvis.gensim_models as gensimvis

pyLDAvis.enable_notebook()

gensimvis.prepare(base_model,corpus,id2word)

我仍然收到錯誤,

錯誤如下。 我正在使用最新版本的 pyLDAvis 3.3.1

在此處輸入圖像描述

pip安裝可能與 Anaconda 不一致。 最好使用conda安裝。

conda install -c conda-forge pyldavis

然后它應該可以與 Anaconda Python 一起正常工作。

嘗試這個

!pip install pyLDAvis
import pyLDAvis.gensim_models

這應該有效。 我遇到了同樣的問題,它對我有用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM