python-3.x 即使已安装sklearn,我也无法导入sklearn

3ks5zfa0  于 2023-03-04  发布在  Python
关注(0)|答案(3)|浏览(218)

我已经安装了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)
1bqhqjot

1bqhqjot1#

如果你使用anaconda,你仍然可以使用pip来安装软件包:

pip install -U scikit-learn scipy matplotlib

对于Python 3.x,请用途:

pip3 install -U scikit-learn scipy matplotlib
oxosxuxt

oxosxuxt2#

首先,请确保您更新pip到最新版本:

python -m pip install --upgrade pip

然后尝试:

pip install -U scikit-learn" on widnows terminal (cmd)

或者用康达试试(如果你的PC上有的话)

conda install scikit-learn

还要确保你已经安装了numpy和scipy

pip install numpy

pip install scipy
gk7wooem

gk7wooem3#

“sklearn”已更改为“scikit-learn”,并且“sklearn”不再有效。
因此在终端中:

pip install -U scikit-learn

更多信息在他们的网站:
https://scikit-learn.org
https://scikit-learn.org/stable/install.html

相关问题