Skip to content
Home » No module named pyLDAvis

No module named pyLDAvis

To solve No module named pyLDAvis error follow below methods. I’d want to use pyLDAvis. It is installed, but I am unable to import it for some reason. After installing pyLDAvis, the message ‘requirement already satisfied’ appears. However, it generates the following error:

ERROR LOG

No module named pyLDAvis

No module named ‘pyLDAvis.gensim

How to solve No module named pyLDAvis ?

Before you can use the package in your code, you must first install it. To install the package and its dependencies, use the following command.

pip install pyldavis

once the installation is done then try :

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)

Alternative to Solve No module named pyLDAvis

Following code worked while using the 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 then the error can be solved using:

import pyLDAvis.gensim_models

instead of:

import pyLDAvis.gensim

Hope the above solution works.

Also read :

ImportError: cannot import name ‘delayed’ from ‘sklearn.utils.fixes’
FutureWarning: The default value of regex will change from True to False in a future version