Python 如何在 anaconda 中升级 scikit-learn 包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33679938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 13:46:06  来源:igfitidea点击:

How to upgrade scikit-learn package in anaconda

pythonscikit-learnanaconda

提问by Sanoj

I am trying to upgrade package of scikit-learn from 0.16 to 0.17. For that I am trying to use binaries from this website: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn. I have Windows 7 x64 bit. I downloaded the relevant package locally and gave following commands and got Requirement already up-to-date:

我正在尝试将 scikit-learn 包从 0.16 升级到 0.17。为此,我正在尝试使用以下网站中的二进制文件:http: //www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn。我有 Windows 7 x64 位。我在本地下载了相关的包并给出了以下命令并获得了最新的需求:

C:\Users\skumar>pip install --upgrade --use-wheel --no-index --find-links=../../
SOURCE/APPS scikit-learn
Ignoring indexes: https://pypi.python.org/simple
Requirement already up-to-date: scikit-learn in c:\anaconda3\lib\site-packages

Then I tried to upgrade it from remote site and got similar result:

然后我尝试从远程站点升级它并得到类似的结果:

C:\Users\skumar>pip install --upgrade --use-wheel --no-index --trusted-host www.
lfd.uci.edu --find-links=http://www.lfd.uci.edu/~gohlke/pythonlibs/ scikit-learn

Ignoring indexes: https://pypi.python.org/simple
Requirement already up-to-date: scikit-learn in c:\anaconda3\lib\site-packages

On Remote site there are two versions i.e., 0.16 & 0.17. Is there a way to specify version in command? Or how do you install/upgrade wheel file?

在远程站点上有两个版本,即 0.16 和 0.17。有没有办法在命令中指定版本?或者你如何安装/升级wheel文件?

回答by Austin A

I would suggest using conda. Conda is an anconda specific package manager. If you want to know more about conda, read the conda docs.

我建议使用 conda。Conda 是 anconda 特定的包管理器。如果您想了解有关 conda 的更多信息,请阅读conda 文档

Using conda in the command line, the command below would install scipy 0.17.

在命令行中使用 conda,下面的命令将安装 scipy 0.17。

conda install scipy=0.17.0

回答by jakevdp

Anaconda comes with the condapackage manager which is designed to handle these kinds of upgrades. Start by updating conda itself to get the most recent package lists:

Anaconda 带有conda包管理器,旨在处理这些类型的升级。首先更新 conda 本身以获取最新的软件包列表:

conda update conda

And then install the version of scikit-learn you want

然后安装你想要的scikit-learn版本

conda install scikit-learn=0.17

All necessary dependencies will be upgraded as well. If you have trouble with conda on Windows, there are some relevant FAQ here: http://docs.continuum.io/anaconda/faq

所有必要的依赖项也将升级。如果您在 Windows 上使用 conda 时遇到问题,这里有一些相关的常见问题解答:http: //docs.continuum.io/anaconda/faq

回答by PyDevSRS

So to upgrade scikit-learn package, you have to follow below process

所以要升级 scikit-learn 包,你必须遵循以下过程

Step-1:Open your terminal(Ctrl+Alt+t)

步骤 1:打开终端(Ctrl+Alt+t

Step-2:Now for checking currently installed packages along with the versions installed on your conda environment by typing conda list

第 2 步:现在通过键入检查当前安装的软件包以及安装在 conda 环境中的版本conda list

Step-3:Now for upgrade type below command

第 3 步:现在升级类型如下命令

conda update scikit-learn

Hope it helps!!

希望能帮助到你!!

回答by Layla

If you are using Jupyter in anaconda, after conda update scikit-learnin terminal, close anaconda and restart, otherwise the error will occur again.

如果你在anaconda中使用Jupyter,conda update scikit-learn在终端之后,关闭anaconda并重启,否则会再次出现错误。

回答by Yogesh

Following Worked for me for scikit-learn on Anaconda-Jupyter Notebook.

以下为我在 Anaconda-Jupyter Notebook 上的 scikit-learn 工作。

Upgrading my scikit-learn from 0.19.1 to 0.19.2 in anaconda installed on Ubuntu on Google VM instance:

在 Google VM 实例上的 Ubuntu 上安装的 anaconda 中将我的 scikit-learn 从 0.19.1 升级到 0.19.2:

Run the following commands in the terminal:

在终端中运行以下命令:

First, check existing available packages with versions by using:

首先,使用以下方法检查现有的可用软件包的版本:

conda list    

It will show different packages and their installed versions in the output. Here check for scikit-learn. e.g. for me, the output was:

它将在输出中显示不同的软件包及其安装的版本。在这里检查 scikit-learn。例如对我来说,输出是:

scikit-learn              0.19.1           py36hedc7406_0  

Now I want to Upgrade to 0.19.2 July 2018 release i.e. latest available version.

现在我想升级到 2018 年 7 月 0.19.2 版,即最新的可用版本。

conda config --append channels conda-forge
conda install scikit-learn=0.19.2

As you are trying to upgrade to 0.17 version try the following command:

当您尝试升级到 0.17 版本时,请尝试以下命令:

conda install scikit-learn=0.17

Now check the required version of the scikit-learn is installed correctly or not by using:

现在使用以下命令检查所需版本的 scikit-learn 是否正确安装:

conda list 

For me the Output was:

对我来说,输出是:

scikit-learn              0.19.2          py36_blas_openblasha84fab4_201  [blas_openblas]  conda-forge

Note: Don't use pip command if you are using Anaconda or Miniconda

注意:如果您使用的是 Anaconda 或 Miniconda,请不要使用 pip 命令

I tried following commands:

我尝试了以下命令:

!conda update conda 
!pip install -U scikit-learn

It will install the required packages also will show in the conda listbut if you try to import that package it will not work.

它将安装所需的包,也将显示在 中,conda list但如果您尝试导入该包,它将无法正常工作。

On the website http://scikit-learn.org/stable/install.htmlit is mentioned as: Warning To upgrade or uninstall scikit-learn installed with Anaconda or conda you should not use the pip.

在网站http://scikit-learn.org/stable/install.html上提到:警告要升级或卸载与 Anaconda 或 conda 一起安装的 scikit-learn,您不应该使用 pip。

回答by bradylange

Updating a Specific Library - scikit-learn:

更新特定库 - scikit-learn

Anaconda (conda):

蟒蛇 ( conda):

conda install scikit-learn

Pip Installs Packages (pip):

Pip 安装包 ( pip):

pip install --upgrade scikit-learn

Verify Update:

验证更新:

conda list scikit-learn

It should now display the current (and desired) version of the scikit-learnlibrary.

它现在应该显示库的当前(和所需)版本scikit-learn

For me personally, I tried using the condacommand to update the scikit-learnlibrary and it acted as if it were installing the latest version to then later discover (with an execution of the conda list scikit-learncommand) that it was the same version as previously and never updated (or recognized the update?). When I used the pipcommand, it worked like a charm and correctly updated the scikit-learnlibrary to the latest version!

就我个人而言,我尝试使用该conda命令来更新scikit-learn库,它就像安装最新版本一样,然后发现(通过执行conda list scikit-learn命令)它与以前的版本相同并且从未更新(或识别)更新?)。当我使用该pip命令时,它就像一个魅力,并正确地将scikit-learn库更新到最新版本!

Hope this helps!

希望这可以帮助!

More in-depth details of latest version can be found here (be mindful this applies to the scikit-learnlibrary version of 0.22):

可以在此处找到最新版本的更多详细信息(请注意,这适用于 的scikit-learn库版本0.22):