简体   繁体   English

如何在 anaconda 中升级 scikit-learn 包

[英]How to upgrade scikit-learn package in anaconda

I am trying to upgrade package of scikit-learn from 0.16 to 0.17.我正在尝试将 scikit-learn 包从 0.16 升级到 0.17。 For that I am trying to use binaries from this website: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn .为此,我尝试使用以下网站中的二进制文件: http : //www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn I have Windows 7 x64 bit.我有 Windows 7 x64 位。 I downloaded the relevant package locally and gave following commands and got Requirement already up-to-date:我在本地下载了相关的包并给出了以下命令并获得了最新的需求:

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 ie, 0.16 & 0.17.在远程站点上有两个版本,即 0.16 和 0.17。 Is there a way to specify version in command?有没有办法在命令中指定版本? Or how do you install/upgrade wheel file?或者你如何安装/升级wheel文件?

Anaconda comes with the conda package manager which is designed to handle these kinds of upgrades. Anaconda 带有conda包管理器,旨在处理这些类型的升级。 Start by updating conda itself to get the most recent package lists:首先更新 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

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.在这里检查 scikit-learn。 eg for me, the output was:例如对我来说,输出是:

scikit-learn              0.19.1           py36hedc7406_0  

Now I want to Upgrade to 0.19.2 July 2018 release ie 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 list but if you try to import that package it will not work.它将安装所需的包,也将显示在conda list但如果您尝试导入该包,它将无法正常工作。

On the website http://scikit-learn.org/stable/install.html it 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。

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 list检查当前安装的软件包以及安装在 conda 环境中的版本

Step-3: Now for upgrade type below command第 3 步:现在升级类型如下命令

conda update scikit-learn

Hope it helps!!希望能帮助到你!!

I would suggest using conda.我建议使用 conda。 Conda is an anconda specific package manager. Conda 是 anconda 特定的包管理器。 If you want to know more about conda, read the conda docs .如果您想了解有关 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

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-learn library.它现在应该显示scikit-learn库的当前(和所需)版本。

For me personally, I tried using the conda command to update the scikit-learn library and it acted as if it were installing the latest version to then later discover (with an execution of the conda list scikit-learn command) that it was the same version as previously and never updated (or recognized the update?).就我个人而言,我尝试使用conda命令来更新scikit-learn库,它就像安装最新版本一样,然后发现(执行conda list scikit-learn命令)它是相同的版本与以前一样并且从未更新(或识别更新?)。 When I used the pip command, it worked like a charm and correctly updated the scikit-learn library to the latest version!当我使用pip命令时,它就像一个魅力一样,并且正确地将scikit-learn库更新到了最新版本!

Hope this helps!希望这可以帮助!

More in-depth details of latest version can be found here (be mindful this applies to the scikit-learn library version of 0.22 ):可以在此处找到最新版本的更多详细信息(请注意,这适用于0.22scikit-learn库版本):

I made it work to update to 0.24.1, on Windows 10 64bits, so I share the way I did it with the GUI:我让它在 Windows 10 64 位上更新到 0.24.1,所以我分享了我用 GUI 做的方式:

  1. launch Anaconda3 gui启动 Anaconda3 gui

  2. on the left menu, click "environments"在左侧菜单上,单击“环境”

  3. next to "base (root)", click on the green arrow/triangle在“base (root)”旁边,点击绿色箭头/三角形

  4. select "Open Terminal"选择“打开终端”

  5. type the command line:输入命令行:

    conda install scikit-learn==0.24.1畅达安装 scikit-learn==0.24.1

It worked without error.它没有错误地工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM