【问题标题】:"Cannot fetch index base URL" error message when attempting to install scikit-learn for Python 3尝试为 Python 3 安装 scikit-learn 时出现“无法获取索引基 URL”错误消息
【发布时间】:2016-08-04 14:26:32
【问题描述】:

我尝试为 Python 3 安装 scikit-learn。我通过以下方式进行安装:

virtualenv model_env
source  model_env/bin/activate
pip3 install sklearn

因此,我收到以下错误消息:

Downloading/unpacking sklearn
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement sklearn
Cleaning up...
No distributions at all found for sklearn

pandas 包我遇到了同样的问题,我已经使用以下命令解决了它:

sudo apt-get install python3-pandas

不幸的是,同样的方法不适用于sklearn

sudo apt-get install python3-sklearn

添加

当我将sklearn 替换为scikit-learn 时,我遇到了同样的问题:

Downloading/unpacking scikit-learn
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement scikit-learn
Cleaning up...
No distributions at all found for scikit-learn

增加了 2 个

正如推荐的那样,我尝试将 pip 与-vvv 结合使用。请注意,我使用pip3 而不是pip。这是我得到的结果:

Downloading/unpacking scikit-learn
  Getting page https://pypi.python.org/simple/scikit-learn/
  Could not fetch URL https://pypi.python.org/simple/scikit-learn/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/scikit-learn/ (Caused by <class 'OSError'>: [Errno 101] Network is unreachable)
  Will skip URL https://pypi.python.org/simple/scikit-learn/ when looking for download links for scikit-learn
  Getting page https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/ (Caused by <class 'OSError'>: [Errno 101] Network is unreachable)
  Will skip URL https://pypi.python.org/simple/ when looking for download links for scikit-learn
  Cannot fetch index base URL https://pypi.python.org/simple/
  URLs to search for versions for scikit-learn:
  * https://pypi.python.org/simple/scikit-learn/
  Getting page https://pypi.python.org/simple/scikit-learn/
  Could not fetch URL https://pypi.python.org/simple/scikit-learn/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/scikit-learn/ (Caused by <class 'OSError'>: [Errno 101] Network is unreachable)
  Will skip URL https://pypi.python.org/simple/scikit-learn/ when looking for download links for scikit-learn
  Could not find any downloads that satisfy the requirement scikit-learn
Cleaning up...
  Removing temporary dir /tmp/pip_build_root...
No distributions at all found for scikit-learn
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python3/dist-packages/pip/req.py", line 1178, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
pip.exceptions.DistributionNotFound: No distributions at all found for scikit-learn

Storing debug log for failure in /home/rngorb/.pip/pip.log

【问题讨论】:

  • sudo pip install -U pip sudo pip install -U scikit-learn
  • 包名是 scikit-learn
  • @Luca, scikit-learn 也不能正常工作(请参阅我的问题的更新)。
  • 听起来 pip 在 pypi 上找不到任何东西...尝试运行 sudo pip -vvv install scikit-learn 以获取更多诊断信息。
  • 要检查网络,您可以尝试 ping pypi.python.org。如果这不起作用,您需要查看您的网络配置。

标签: python scikit-learn python-3.4


【解决方案1】:

尝试使用

pip3 install scikit-learn

【讨论】:

  • 它没有帮助,我仍然有同样的问题(同样的错误信息)。
【解决方案2】:

首先更新你的点子:

pip3 install --upgrade pip

然后使用 arg "--user" 安装 scikit-learn。不要将 sudo 与 pip 一起使用,因为它会产生问题:

pip install --user scikit-learn

【讨论】:

    【解决方案3】:

    也许您应该考虑使用Anaconda,它默认包含这两个包,并使用管理enviromentspackages 的工具让您的生活更轻松

    【讨论】:

    • @Roman 我还发现使用 Anaconda 是安装这些软件包的最简单方法。 Here 是使用 Anaconda 安装 scikit-learn 的示例。
    【解决方案4】:

    我可以用这个命令解决它:

    py -m pip install --user NAME_OF_THE_LIBRARY
    

    它适用于 - NumPy、SciPy、matplotlib、ipython、jupyter、pandas、sympy、nose 和 scikit-learn

    【讨论】:

    • 你确定吗? “--user”和“NAME_OF_THE_LIBRARY”似乎不适合
    • 是的,我确定。例如 para o 'numpy' 将是: py -m pip install --user numpy 我已经以这种方式安装了所有库。它在 Python3 中工作的唯一方式。
    【解决方案5】:

    如果你想要 Anaconda 包的便利性但又想要pip 包管理的灵活性和极简主义,我建议你试试miniconda

    一旦你安装了 miniconda(记住 source ~/.bash_profilesource ~/.bashrc),你可以这样做来设置你的环境:

    conda create -n myenv scikit-learn pip python=3
    

    这将为您提供一个带有 sklearn 和 pip 的 conda env,以防您想要安装不支持作为 conda 包的库。 pip 在 conda 环境中运行。

    【讨论】:

      【解决方案6】:

      基于answer 问题Python pip error: “Cannot fetch index base URL https://pypi.python.org/simple/” 我会尝试使用easy_install 重新安装(和升级)pip

      easy_install pip==8.1.2
      

      我尝试重现您的问题,在 pyenv-3.4 创建的虚拟环境中,在 pip install numpypip install scipy 之后安装 scikit-learn 成功。

      【讨论】:

        【解决方案7】:

        如果您有多个版本的 Python,请确保在安装之前位于正确的站点包路径。

        对我来说就是这样!!!

        【讨论】:

          【解决方案8】:

          它工作得很好。尝试在全局环境中安装 sklearn,即直接在终端中。对于 Ubuntu 17.04(+ 最新版本)尝试-

          sudo apt-get install python3-sklearn

          同样,对于熊猫

          sudo apt-get install python3-pandas

          【讨论】:

          • 这特别适用于基于 deb 的发行版,例如 Ubunut、Kali-linux 及其风格。如果此命令有任何问题,请告诉我。
          • 这些是简单的 apt-get 命令来安装 python 库,还有其他包管理器允许用户下载旧版本的库,例如conda、外星人等。
          猜你喜欢
          • 2021-02-01
          • 2015-01-15
          • 2018-05-08
          • 2018-10-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-12-21
          • 1970-01-01
          相关资源
          最近更新 更多