【问题标题】:Extremely slow pip installs极慢的 pip 安装
【发布时间】:2018-06-10 19:54:37
【问题描述】:

任何与 pypi 联系的 pip 命令在 Ubuntu 18.04 上运行速度都非常慢。

$ pip install -v pandas                        
Created temporary directory: /tmp/pip-ephem-wheel-cache-hvbcg1k_
Created temporary directory: /tmp/pip-install-7_spppvw
Collecting pandas
  1 location(s) to search for versions of pandas:
  * https://pypi.org/simple/pandas/
  Getting page https://pypi.org/simple/pandas/
  Looking up "https://pypi.org/simple/pandas/" in the cache
  Current age based on date: 324440
  Freshness lifetime from max-age: 600
  Freshness lifetime from request max-age: 600
  Starting new HTTPS connection (1): pypi.org

挂起约 1-2 分钟(至少)。

使用选项--index-url=http://pypi.python.org/simple/ 可以大大加快速度,但似乎并不理想,因为它会跳过加密。有什么解决方法吗?

【问题讨论】:

    标签: python-3.x pip ipv6


    【解决方案1】:

    此症状可能表示 IPv6 路由或 DNS 问题。遇到此问题的任何人都可以尝试禁用 IPv6 作为解决方法,直到找到根本原因。您可以通过执行以下操作暂时禁用 Ubuntu 上的 IPv6(直到下次重新启动):

    sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
    sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
    

    【讨论】:

      【解决方案2】:

      我在 MacOS (Catalina) 上遇到了这个问题,禁用 IPv6 为我解决了这个问题。 (感谢@stevegt 之前的回答为我指明了正确的大方向。)我使用this guide 在我的Mac 上禁用了IPv6;就我而言,指南将我带到了这个命令:

      networksetup -setv6off Wi-Fi
      

      【讨论】:

        【解决方案3】:

        与@stevegt 的建议差不多,请查看他的回答。

        现在,如果您认为问题是 ipv6,请运行快速测试以确认 https://ipv6-test.com/。

        如果您确实遇到了 ipv6 问题,可能是您的 ISP 不支持它,在这种情况下请投诉,不要让他们侥幸逃脱。

        与此同时,您可能希望在您的机器上完全disable ipv6 以避免此类问题(连接缓慢等)。我建议您在启动时通过将ipv6.disable=1 添加到kernel parameters 来在内核上禁用它。

        【讨论】:

          猜你喜欢
          • 2020-05-22
          • 2011-11-18
          • 1970-01-01
          • 1970-01-01
          • 2012-12-20
          • 2019-05-30
          • 2015-08-05
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多