Monday, March 29, 2021

Python3 pip is slow on install

`python3 -m pip install` was hanging when trying to install packages.

 

Update with a much easier way is to force the system to prefer ipv4 instead of ipv6:

Pip installs slowly due to ubuntu’s preference for ipv6, in /etc/gai.conf add the line (or uncomment the existing line)

precedence ::ffff:0:0/96 100 to indicate a preference for ipv4. This will stop pip from hesitating before installing packages.

 

Older method:

Searched for `pip hangs on "Starting new HTTPS connection (1): pypi.org:443"` and found a single link which linked to https://github.com/pypa/pip/issues/5469#issuecomment-393919476, which ultimately lead to a tutorial at https://support.purevpn.com/how-to-disable-ipv6-linuxubuntu. Essentially

  • edit /etc/sysctl.conf to add
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    net.ipv6.conf.lo.disable_ipv6 = 1
  • run `sudo sysctl -p`
  • confirm with `cat /proc/sys/net/ipv6/conf/all/disable_ipv6`

No comments:

Post a Comment