pip 安装速度极慢

Car*_*rro 7 pip ipv6 python-3.x

任何与 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
Run Code Online (Sandbox Code Playgroud)

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

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

ste*_*egt 18

此症状可能表示 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
Run Code Online (Sandbox Code Playgroud)


Joe*_*van 5

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

networksetup -setv6off Wi-Fi
Run Code Online (Sandbox Code Playgroud)