I can't import pyLDAvis.
It is installed but for some reason, I can not import it.
I tried
conda update anaconda
pip install --upgrade pip
pip install --upgrade jupyter notebook
pip install pyLDAvis
Installing pyLDAvis returns the message 'requirement already satisfied'. So I tried uninstalling and reinstalled the package but still doesn't work. This never happened with any other packages.
How can I solve this problem?
The pyLDAvis gensim name changed. When I use gensim_models rather than gensim the interactive viz works.
The 'gensim_models' name is in the latest commit to bmabey's 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)
Following code worked for me and I'm using 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
If you are working in jupyter notebook (python vs3.3.0)
"the No module named 'pyLDAvis.gensim'"
error can be solved using:
import pyLDAvis.gensim_models
instead of:
import pyLDAvis.gensim
Please follow the below
import pyLDAvis.gensim_models as gensimvis
pyLDAvis.enable_notebook()
vis = gensimvis.prepare(lda_model, corpus, dictionary)
vis
The pip
installation may not agree with Anaconda. It is better to use conda
installation.
conda install -c conda-forge pyldavis
Then it should work fine with Anaconda Python.
Try this
!pip install pyLDAvis
import pyLDAvis.gensim_models
This should work. I faced the same issue and it worked for me
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.