Search code examples
pythonpippypi

Pip network error (and I am not using a proxy!)


I am using Ubuntu 16.04 and I often get the infamous pip network error:

$ pip3 install matplotlib
Collecting matplotlib
...
...
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

It works sometimes, most often it does not. I have to try many, many times until I get something installed.

Unlike the many people who have reported similar problems, I am not behind a proxy and I have already tried different networks, both physically and using VPN.

I think the problem is that https://pypi.org/ is often unavailable for me. Most of the time, I cannot access the website.

enter image description here

I don't know if this is country-specific (Portugal here), but other colleagues of mine have similar problems.

A lot of people say to download get-pip.py from here and install pip manually. But that website is down as well. I have managed to download get-pip.py from somewhere else, but then I get the same pypi error.


Solution

  • It looks like this is a known issue affecting a Portuguese ISP company. This company doesn't handle well the IPv6 protocol, and pip gives an error. Disabling IPv6 fixes the problem.

    In Linux, IPv6 can be temporarily disabled by doing sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6.