zoukankan      html  css  js  c++  java
  • Python: 安装 sklearn 包出现错误的解决方法

    今天在安装 Python 的 sklearn 包时出现了 Cannot uninstall 'numpy' 和 Cannot uninstall 'scipy' 错误,下面记录了我尝试了很多网上的方法后最终成功的解决方法。

    出现此类错误的主要原因应该是电脑上已安装的 numpy 和 scipy 版本不够高,pip 下载 sklean 时指令会自动删除版本不够的 numpy 和 scipy,删除过程中出现无法删除的错误,所以解决办法就是要手动先升级 numpy 和 scipy。若是要在 python 3 下安装,下面的所有指令中 pip 用 pip3 替代。

    我的电脑是 Mac 系统,不确定 Linux 是否也是相同的解决指令,但思路应该是相同。

    以下为具体操作:

    终端执行 pip install scikit-learn 后,出现 Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

    执行 sudo pip install --upgrade --ignore-installed --install-option '--install-data=/usr/local' numpy 后成功升级 numpy。

    再次执行 pip install scikit-learn ,出现 Cannot uninstall 'scipy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

    执行 sudo pip install --upgrade scipy --ignore-installed six ,成功升级 scipy

    再次执行 pip install scikit-learn 后出现权限问题,运行 sudo pip install scikit-learn ,成功安装 sklearn 包(见下图)。

    另外,我在 Python 3 下安装 scikit-learn 没有出现该类错误,应该是因为 numpy 和 scipy 的版本够高。

  • 相关阅读:
    第72届奥斯卡最佳动画奖《老人与海》
    关不掉的手机应用程序
    李嘉诚:知识并不一定使你的财富增加
    Linux之父Linus Torvalds谈软件开发管理经验
    Google 正式发布Dart编程语言
    代码本身其实并不重要,重要的是用户
    22个基于HTML5开发的网站
    看看耶鲁大学心态 ,送给正在奋斗的人 !
    用 git 维护 vim 代码
    谈程序语言的设计及程序员心态
  • 原文地址:https://www.cnblogs.com/zhenqichai/p/fix-pip-install-sklearn-problem.html
Copyright © 2011-2022 走看看