andrewtavis/kwx

ModuleNotFoundError: No module named 'pyLDAvis.gensim'

Closed this issue · 5 comments

Hi Andrew,
I found this ModuleNotFoundError while running the line

from kwx.model import extract_kws

Error description:
25 import pandas as pd
26 import pyLDAvis
---> 27 import pyLDAvis.gensim
28 import seaborn as sns
29 from gensim import corpora

ModuleNotFoundError: No module named 'pyLDAvis.gensim'

But, it can be solved by installing :
pip install pyLDAvis==3.2.2

Hi Abhishek, and thanks for your interest and reporting this!

It looks like later versions of pyLDAvis changed the logic of how the gensim module was passed, and it's now gensim_models or gensimvis - see their history. The environment and requirement files for kwx have a valid 3.2.0 version as a dependency, so I'll leave this for now, but thank you for the documentation on this!

Let me know if there's something explicit you think should happen :)

Or actually, sorry, I will take a look at this and see if there's a way to get this working on the most recent version of pyLDAvis. Will update you on the progress of this, and thanks for reporting :)

Literally was as easy as updating to the most recent version and switching import pyLDAvis.gensim to import pyLDAvis.gensim_models (included in a try statement) as well as its usage in the code :) I've also updated the requirements and environment files to allow for the most recent version :) All this is going through in #29.

Thanks again for these issues! Were very helpful 😊

Thanks, Andrew!

EDIT : Maybe you also need to update the PyPi index/config, since this issue is still seen on fresh pip install for now.

@AbhiPawar5, did you do a pip install update, as in:

pip install kwx -U

I did do an update of PyPI (FYI - capital I in PyPI, which is a common mistake 😊). If it's still happening with an update then I'll reopen this and give it another look :)