cemoody / lda2vec

MIT License
3.15k stars 628 forks source link

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

Open gaowenxin95 opened 4 years ago

gaowenxin95 commented 4 years ago

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 commented 4 years ago

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.

rohit901 commented 3 years ago

What's the fix for this?

ludodorcel commented 2 years ago

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