导入错误:导入 PCA 时无法导入名称"潜在狄利克雷分配"



我不断收到错误:

ImportError: cannot import name 'LatentDirichletAllocation'

完整回溯:

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'

当我尝试使用以下方法导入 PCA 时:

sklearn.decomposition import PCA

我删除了 sklearn 文件夹,但仍然收到错误。

安装中断。

尝试:

对于 Python 2

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

对于 Python 3

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

遇到此问题,通过pip完全卸载并重新安装scikit-learn

最新更新