任何与 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/
大大加快了速度,但似乎并不理想,因为它跳过了加密。有什么解决方法吗?
最佳答案
此症状可能表示 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
关于python-3.x - pip 安装速度极慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50787522/