lda2vec
lda2vec copied to clipboard
ImportError: cannot import name 'preprocess' from 'lda2vec' (D:\anaconda3\lib\site-packages\lda2vec\__init__.py)
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
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.
What's the fix for this?
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