Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Jupyter Notebook cannot import pyLDAvis.sklearn

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading