ImportError: cannot import name 'LatentDirichletAllocation' when importing PCA
ImportError: cannot import name 'LatentDirichletAllocation' when importing 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 文件夹,但仍然出现错误。
有这个问题,完全卸载并重新安装 scikit-learn
到 pip
修复了它。
安装失败。
尝试:
对于Python 2
pip uninstall scikit-learn
pip install -U scikit-learn==0.20.4
为Python3
pip3 uninstall scikit-learn
pip3 install -U scikit-learn==0.21.3
我一直收到错误消息:
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 文件夹,但仍然出现错误。
有这个问题,完全卸载并重新安装 scikit-learn
到 pip
修复了它。
安装失败。
尝试:
对于Python 2
pip uninstall scikit-learn
pip install -U scikit-learn==0.20.4
为Python3
pip3 uninstall scikit-learn
pip3 install -U scikit-learn==0.21.3