Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyLDAvis.gensim needs to be imported explicitly #131

Closed
martin-martin opened this issue Aug 6, 2018 · 12 comments
Closed

pyLDAvis.gensim needs to be imported explicitly #131

martin-martin opened this issue Aug 6, 2018 · 12 comments

Comments

@martin-martin
Copy link
Contributor

I keep getting AttributeError when attempting to run:

import pyLDAvis

# ... creating LDA model, corpus, and dictionary in here
pyLDAvis.gensim.prepare(ldamodel, corpus, dictionary)

Here's the traceback:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-950ae09ed90b> in <module>()
----> 1 pyLDAvis.gensim.prepare(ldamodel, corpus, dictionary)

AttributeError: module 'pyLDAvis' has no attribute 'gensim'

However, the code runs fine when importing gensim explicitly:

from pyLDAvis import gensim

# ... same as above
gensim.prepare(ldamodel, corpus, dictionary)

Unsure why that would be the case? Is it possible that gensim would need to be added to __init__.py?

@priyaananthasankar
Copy link

How about this: import pyLDAvis.gensim This doesn't give me Attribute Error

@maykyawtthu
Copy link

import pyLDAvis.gensim gives me import error. How can i solve it?

@anandi1989
Copy link

import pyLDAvis.gensim gives me import error. How can i solve it?

Looks like this is latest issue with version 3.3.0

Switch to version 3.2.2 and it will work like charm.

@msusol
Copy link
Collaborator

msusol commented Mar 23, 2021

vs3.3.0 had to rename the file name, so now use import pyLDAvis.gensim_models

Note: the colab examples have import pyLDAvis.gensim AS gensimvis, and I could rename the file to gensimvis.py then it would simply be import pyLDAvis.gensimvis

@msusol msusol closed this as completed Mar 23, 2021
@anandi1989
Copy link

vs3.3.0 had to rename the file name, so now use import pyLDAvis.gensim_models

Note: the colab examples have import pyLDAvis.gensim AS gensimvis, and I could rename the file to gensimvis.py then it would simply be import pyLDAvis.gensimvis

Thanks for the quick action.

@hminooei
Copy link

I had the same issue with pyLDAvis==3.2.2 and the above solution (import pyLDAvis.gensim_models) surprisingly worked, am I missing something?

@VictorSuarezL
Copy link

Still have the same problem. Any tips?

@anandi1989
Copy link

Still have the same problem. Any tips?

change the version to pyLDAvis==3.2.1

@Brice-KENGNI-ZANGUIM
Copy link

Brice-KENGNI-ZANGUIM commented Jul 17, 2022

hello everyone.
I'm using python 3.9.12 and have the same Error with : import pyLDAvis.gensim
i also try : from pyLDAvis import gensim but don't work

I solve it by importing the package gensim_models instead of gensim : import pyLDAvis.gensim_models

I still don't understand why but it work.

@907Resident
Copy link

907Resident commented Sep 30, 2022

hello everyone. I'm using python 3.9.12 and have the same Error with : import pyLDAvis.gensim i also try : from pyLDAvis import gensim but don't work

I solve it by importing the package gensim_models instead of gensim : import pyLDAvis.gensim_models

I still don't understand why but it work.

Yes, this worked for me as well. Unfortunately, I do not know the reason but I found the answer also without further explanation on stack: https://stackoverflow.com/a/71920375

@ChathuraGal
Copy link

hello everyone. I'm using python 3.9.12 and have the same Error with : import pyLDAvis.gensim i also try : from pyLDAvis import gensim but don't work

I solve it by importing the package gensim_models instead of gensim : import pyLDAvis.gensim_models

I still don't understand why but it work.

It worked for me too

@msusol
Copy link
Collaborator

msusol commented Apr 19, 2023

I solve it by importing the package gensim_models instead of gensim : import pyLDAvis.gensim_models

I still don't understand why but it work.

#131 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants