ImportError: cannot import name 'LatentDirichletAllocation' when importing PCA [closed]

橙三吉。 提交于 2019-12-24 06:13:37

问题


I keep getting the error:

ImportError: cannot import name 'LatentDirichletAllocation'

full traceback:

Traceback (most recent call last):
  File "/home/path/to/file/pca.py", line 7, in <module>
    from sklearn.decomposition import PCA
  File "/home/user/.local/lib/python3.6/site-packages/sklearn/decomposition/__init__.py", line 19, in <module>
    from ._online_lda import LatentDirichletAllocation
ImportError: cannot import name 'LatentDirichletAllocation'

when I try to import PCA using:

sklearn.decomposition import PCA

I deleted the sklearn folder and still get the error.


回答1:


Broken installation.

Try:

For Python 2

pip uninstall scikit-learn
pip install -U scikit-learn==0.20.4

For Python 3

pip3 uninstall scikit-learn
pip3 install -U scikit-learn==0.21.3



回答2:


Had this problem, fully uninstalling and re-installing scikit-learn via pip fixed it.



来源:https://stackoverflow.com/questions/59321650/importerror-cannot-import-name-latentdirichletallocation-when-importing-pca

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!