andrewtavis / kwx

BERT, LDA, and TFIDF based keyword extraction in Python
BSD 3-Clause "New" or "Revised" License
70 stars 10 forks source link

ModuleNotFoundError: No module named 'pyLDAvis.gensim' #25

Closed AbhiPawar5 closed 3 years ago

AbhiPawar5 commented 3 years ago

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

andrewtavis commented 3 years ago

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 :)

andrewtavis commented 3 years ago

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 :)

andrewtavis commented 3 years ago

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 😊

AbhiPawar5 commented 3 years ago

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.

andrewtavis commented 3 years ago

@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 :)