question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with import from LatentDirichletAllocation

See original GitHub issue

Some people are getting an issue after updating scikit-learn:

  File "/home/jupyter/.local/lib/python3.5/site-packages/sklearn/decomposition/__init__.py", line 19, in <module>
    from ._online_lda import LatentDirichletAllocation
ImportError: cannot import name 'LatentDirichletAllocation'

There an SO question about it: https://stackoverflow.com/questions/59240556/latentdirichletallocation-was-not-installed-in-decomposition-module-of-scikit-le

and we got an issue reported in imbalanced-learn: https://github.com/scikit-learn-contrib/imbalanced-learn/issues/663

I assume that this is not just bad luck. However, I cannot reproduce it locally. It is for sure linked to the privatization of the online_lda module but I don’t get how to trigger that.

NB: I will write an answer in the so because the “solution” is a really bad fix and if we could get feedback on this issue to solve it, it would be great.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
glemaitrecommented, Dec 13, 2019

OK so the issue is due to the following file _online_lda.cpython-36m-x86_64-linux-gnu.so

Before we had a _online_lda.pyx and therefore we were generated the associated so file. We renamed it to _online_lda_fast.pyx. In the same time, we renamed online_lda.py to _online_lda.py.

Basically, during pip install scikit-learn -U, the .so does not get removed and we have a collision between the naming. To solve this issue, you need to remove the file by hand.

1reaction
NicolasHugcommented, Dec 13, 2019

Did we have some other cases where we renamed the pyx file and took the same name for the py file. We will have the same issue for this one as well.

I think _k_means.py[x] and _hierarchical.py[x] also qualify

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot import name 'LatentDirichletAllocation' from 'sklearn ...
I think this might be a problem with conda install sklearn version 0.22 as questioned in this issues. Try pip install -U scikit-learn....
Read more >
sklearn.decomposition.LatentDirichletAllocation
LatentDirichletAllocation : Topic extraction with Non-negative Matrix Factorization ... from sklearn.decomposition import LatentDirichletAllocation >>> from ...
Read more >
Latent Dirichlet Allocation using Scikit-learn
In this tutorial, we will focus on Latent Dirichlet Allocation (LDA) and perform topic modeling using Scikit-learn.
Read more >
Topic Modeling using Latent Dirichlet Allocation - easiest way
Step 1 – Importing required libraries. Step 2 – Reading input data. Step 3 – Checking info of our data. Step 4 –...
Read more >
Topic Modeling in Python: Latent Dirichlet Allocation (LDA)
It is key to understanding the data and ensuring we are on the right track, and if any more preprocessing is necessary before...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found