【问题标题】:Pip hangs on Starting new HTTPS connectionPip 在开始新的 HTTPS 连接时挂起
【发布时间】:2019-09-18 12:20:59
【问题描述】:

我正在尝试构建 docker 映像的 docker 实例中运行 docker。然而,在构建过程中,一切都挂在pipe install 命令上。我的基础镜像是 nvidia/cuda:10.1-base-ubuntu16.04。

这是我试图在我的 Dockerfile 中运行的命令

  python -m pip --no-cache-dir --default-timeout=1000 install -U jupyter \
  jupyter_contrib_nbextensions \
  jupytext -vvv &&\

这里有详细的日志

Collecting jupyter
  1 location(s) to search for versions of jupyter:
  * https://pypi.org/simple/jupyter/
  Getting page https://pypi.org/simple/jupyter/
  Found index url https://pypi.org/simple
  Starting new HTTPS connection (1): pypi.org:443
  https://pypi.org:443 "GET /simple/jupyter/ HTTP/1.1" 200 496
  Analyzing links from page https://pypi.org/simple/jupyter/
    Found link https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl#sha256=5b290f93b98ffbc21c0c7e749f054b3267782166d72fa5e3ed1ed4eaf34a2b78 (from https://pypi.org/simple/jupyter/), version: 1.0.0
    Found link https://files.pythonhosted.org/packages/c9/a9/371d0b8fe37dd231cf4b2cff0a9f0f25e98f3a73c3771742444be27f2944/jupyter-1.0.0.tar.gz#sha256=d9dc4b3318f310e34c82951ea5d6683f67bed7def4b259fafbfe4f1beb1d8e5f (from https://pypi.org/simple/jupyter/), version: 1.0.0
    Found link https://files.pythonhosted.org/packages/fc/21/a372b73e3a498b41b92ed915ada7de2ad5e16631546329c03e484c3bf4e9/jupyter-1.0.0.zip#sha256=3e1f86076bbb7c8c207829390305a2b1fe836d471ed54be66a3b8c41e7f46cc7 (from https://pypi.org/simple/jupyter/), version: 1.0.0
  Given no hashes to check 3 links for project 'jupyter': discarding no candidates
  Using version 1.0.0 (newest of versions: 1.0.0)
  Created temporary directory: /tmp/pip-unpack-i95zt6ip
  Starting new HTTPS connection (1): files.pythonhosted.org:443

还有其他运行的日志

Collecting jupyter
  1 location(s) to search for versions of jupyter:
  * https://pypi.org/simple/jupyter/
  Getting page https://pypi.org/simple/jupyter/
  Found index url https://pypi.org/simple
  Starting new HTTPS connection (1): pypi.org:443

如您所见,它挂在Starting new HTTPS connection (1): 上,有时它通过第一个但在第二个失败。

我根据其他答案添加了--no-cache-dir--default-timeout=1000,但这对我没有帮助。我的 pip install 工作过一次,但在我有 -vvv 选项之前,所以不知道它如何完成,但是我的 Dockerfile 包含三个 pip install 命令,后来它在第二个命令上失败了。

最大的问题是我无法获得构建该 docker 映像的机器的配置,当我在本地尝试时,一切正常。是一个pip install 还是多个都没关系。

所以,我的问题是:pip 在那一刻挂起的原因是什么?

【问题讨论】:

  • 你使用哪个基础镜像?
  • @LinPy 我正在使用 nvidia/cuda:10.1-base-ubuntu16.04
  • 建议你先尝试更新pip
  • @LinPy 谢谢,但没有帮助。

标签: python docker pip


【解决方案1】:

在我的机器上禁用 IPv6 支持为我解决了这个问题。
适用于 ubuntu 20.04
打开配置文件设置系统变量

sudo vi /etc/sysctl.conf

将以下行添加到末尾

net.ipv6.conf.all.disable_ipv6 = 1 
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

加载设置

sudo sysctl -p

通过查看 disable_ipv6 标志来验证设置。如果显示0上述步骤之一失败,则应显示1

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

来源:https://github.com/pypa/pip/issues/5469#issuecomment-393919476

【讨论】:

  • 在 letbox 上遇到:ipv6 已启用,但没有附加公共地址。完全禁用 ipv6 确实解决了这个问题
【解决方案2】:

我不知道如何在那种环境中使用pip install,但我找到了解决方法。

需要在该 docker 映像上安装 anaconda(miniconda3) 而不是使用 pip install 我开始使用 conda install 进行内部包管理。 conda 似乎没有任何问题,所以这绝对是 pip 的问题。

【讨论】:

    【解决方案3】:

    这应该可行:

    FROM nvidia/cuda:10.1-base-ubuntu16.04
    
    RUN apt-get update &&  apt-get install -y python3 python3-pip
    RUN pip3 install --upgrade pip
    RUN python3 -m pip --no-cache-dir --default-timeout=1000 install -U jupyter \
      jupyter_contrib_nbextensions \
      jupytext -vvv \
    

    请注意将安装 python3.5 ,这应该可以工作,因为 jupyterpython3.3 开始工作

    【讨论】:

    • 抱歉,忘记回复了。不幸的是,它没有用。
    • 和以前一样,它挂在 pip 上。我会尝试以不同的方式修复它,如果我发现任何东西,我会发布,谢谢你的帮助。
    【解决方案4】:

    这可能与在公司网络或 VPN 上有关。 Se这个相关问题:Temporary failure in name resolution [Errno -3] with Docker

    【讨论】:

      猜你喜欢
      • 2019-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 2016-07-21
      • 2019-01-21
      • 2019-01-29
      • 1970-01-01
      相关资源
      最近更新 更多