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

ImportError: cannot import name 'preprocess' from 'lda2vec' (D:\anaconda3\lib\site-packages\lda2vec\__init__.py) #103

Open
gaowenxin95 opened this issue Jul 10, 2020 · 3 comments

Comments

@gaowenxin95
Copy link

hi, l hace installed lda2vec by "pip setup,py install"
but when l run code,l got this errors

from lda2vec import Lda2vec,word_embedding
from lda2vec import preprocess, corpus
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline

try:
    import seaborn
except:
    pass
Using TensorFlow backend.
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-8438244e518f> in <module>()
      1 from lda2vec import Lda2vec,word_embedding
----> 2 from lda2vec import preprocess, corpus
      3 import matplotlib.pyplot as plt
      4 import numpy as np
      5 get_ipython().run_line_magic('matplotlib', 'inline')

ImportError: cannot import name 'preprocess' from 'lda2vec' (D:\anaconda3\lib\site-packages\lda2vec\__init__.py)

@cemoody @cesarsalgado @intohole @matheusportela

@JiaxiangBU
Copy link

JiaxiangBU commented Jul 12, 2020

I have the same installation bug.

$ python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>> import lda2vec
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\work\lda2vec\lda2vec\__init__.py", line 1, in <module>
    import dirichlet_likelihood
ModuleNotFoundError: No module named 'dirichlet_likelihood'
>>> exit()

Here is the reproducible code from #86

python setup.py build
python setup.py install

It seems the import relative path is invalid, I temporally rebuild this module in the nbdev framework, have a try.

JiaxiangBU added a commit to JiaxiangBU/lda2vec that referenced this issue Jul 12, 2020
@rohit901
Copy link

What's the fix for this?

@ludodorcel
Copy link

You need to replace every import line as "import blabla" by "from . import blabla" in init.py.
Then there is more few error :
• In preprocess.py replace : "from spacy.en import English" by : "import spacy from spacy.lang.en import English"
• Add parenthesis around print function in :
• file corpus.py line 579
• file topics.py line 106

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

4 participants