无法安装最新版本的 scikit-learn

无法安装最新版本的 scikit-learn

我正在使用 Debian Stable Linux 和 Python 版本 3.7.3,其他方面运行良好。我安装了 scikit-learn (sklearn) 版本 0.22.2,我想将其升级到最新版本 0.23

我正在使用以下命令,但它们不起作用:

$ python3 -m pip install --user scikit-learn 
Requirement already satisfied: scikit-learn in /home/abcd/.local/lib/python3.7/site-packages (0.22.2)
Requirement already satisfied: joblib>=0.11 in /home/abcd/.local/lib/python3.7/site-packages (from scikit-learn) (0.14.1)
Requirement already satisfied: numpy>=1.11.0 in /home/abcd/.local/lib/python3.7/site-packages (from scikit-learn) (1.18.1)
Requirement already satisfied: scipy>=0.17.0 in /home/abcd/.local/lib/python3.7/site-packages (from scikit-learn) (1.4.1)


$ python3 -m pip install --user sklearn
Requirement already satisfied: sklearn in /home/abcd/.local/lib/python3.7/site-packages (0.0)
Requirement already satisfied: scikit-learn in /home/abcd/.local/lib/python3.7/site-packages (from sklearn) (0.22.2)
Requirement already satisfied: joblib>=0.11 in /home/abcd/.local/lib/python3.7/site-packages (from scikit-learn->sklearn) (0.14.1)
Requirement already satisfied: scipy>=0.17.0 in /home/abcd/.local/lib/python3.7/site-packages (from scikit-learn->sklearn) (1.4.1)
Requirement already satisfied: numpy>=1.11.0 in /home/abcd/.local/lib/python3.7/site-packages (from scikit-learn->sklearn) (1.18.1)

问题出在哪里?如何解决?

注:pip也升级至最新版本。

正如评论所指出的,pip show命令的输出:

$ python3 -m pip show scikit-learn
Name: scikit-learn
Version: 0.22.2
Summary: A set of python modules for machine learning and data mining
Home-page: http://scikit-learn.org
Author: None
Author-email: None
License: new BSD
Location: /home/abcd/.local/lib/python3.7/site-packages
Requires: joblib, scipy, numpy
Required-by: yellowbrick, tsfresh, sklearn, pingouin, MindsDB, lightwood

答案1

我正在使用以下命令,但它们不起作用:

$ python3 -m pip install --user scikit-learn
[...]
$ python3 -m pip install --user sklearn

当使用 更新现有的已安装 Python 包时pip install,通常应该包括--升级(-U)选项例如:

python3 -m pip install --upgrade --user scikit-learn

python3 -m pip install --upgrade --user sklearn

该选项可自动卸载软件包的先前版本,然后收集并安装可用的最新版本pip

从技术上讲,您也可以在pip uninstall使用之前使用 自行卸载该软件包pip install,但使用--upgrade选项可以省去一个步骤。


根据您的需要,还可以使用--忽略已安装 (-I)选项(它只是忽略所有已安装的软件包并覆盖它们)。但这可能会根据情况损坏您的系统,因此不应将其用于一般升级。


答案2

您可以尝试从 Debian 软件包档案中安装它。打开终端并运行:

sudo apt-get update
sudo apt-get install python3-sklearn python3-sklearn-lib

相关内容