I am using Jupyter Notebook to run python code. I already did the following:
!pip install pyldavis
I can successfully import pyLDAvis via the following codes:
import pyLDAvis
pyLDAvis.enable_notebook()
However, I cannot import pyLDAvis.sklearn via the following codes:
import pyLDAvis.sklearn
It returns:
ModuleNotFoundError Traceback (most recent call last) Cell In[52], line 1 ----> 1 import pyLDAvis.sklearn_models
ModuleNotFoundError: No module named 'pyLDAvis.sklearn_models'
Why is that and what should I do to deal with it?
It looks like there has been a change in how the software handles this pattern.
This issue posted here in May of this year (2023) that looks to be the same as yours.
It links over to a solution that details how the use of the software has recently developed:
"pyLDAvis v 3.4.0 no longer has the file sklearn.py in the pip package." Replace any logic involving:
import pyLDAvis.sklearn
...
pyLDAvis.sklearn.prepare
"with"
import pyLDAvis.lda_model
...
pyLDAvis.lda_model.prepare
How this was found via troubleshooting:
I went to the page for the package in the Python Package Index (PyPI) and clicked on 'GitHub statistics:' on the left side under 'GitHub statistics:'. Then in the 'filters' slot I entered 'pyLDAvis.sklearn
'.
The four that came up as open didn't look too similar to the OP, and so I clicked on the '7 closed
' tag above the listing. The most recent one listed 'ModuleNotFoundError: No module named 'pyLDAvis.sklearn'
looked to be a good match to this post, and so I examined it.