我已经安装了 sklearn,但是当我运行一个导入 sklearn 的 python 文件时,我得到了这个:
Traceback (most recent call last):
File "first.py", line 3, in <module>
from sklearn import datasets
ModuleNotFoundError: No module named 'sklearn'
这是我安装sklearn时的结果:
Requirement already satisfied: scikit-learn in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (0.24.0)
Requirement already satisfied: numpy>=1.13.3 in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from scikit-learn) (1.19.4)
Requirement already satisfied: scipy>=0.19.1 in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from scikit-learn) (1.5.4)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from scikit-learn) (2.1.0)
Requirement already satisfied: joblib>=0.11 in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from scikit-learn) (1.0.0)
答案 0 :(得分:0)
首先,确保您将 pip 更新到最新版本:
python -m pip install --upgrade pip
然后尝试:
pip install -U scikit-learn" on widnows terminal (cmd)
或者用 conda 试试(如果你的电脑上有它)
conda install scikit-learn
还要确保你已经安装了 numpy 和 scipy
pip install numpy
pip install scipy
答案 1 :(得分:0)
如果您使用 anaconda,您仍然可以使用 pip 安装软件包:
pip install -U scikit-learn scipy matplotlib
对于 Python 3.x 使用:
pip3 install -U scikit-learn scipy matplotlib