7

Any sort of pip command that contacts pypi is running extremely slow on 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

Which hangs for ~1-2 minutes (at least).

Using the option --index-url=http://pypi.python.org/simple/ speeds it up a lot, but doesn't seem to be ideal because it skips encryption. Is there any workaround for this?

3 Answers 3

22

This symptom can indicate an IPv6 routing or DNS problem. Anyone hitting this might try disabling IPv6 as a workaround until you find the root cause. You can temporarily disable IPv6 on Ubuntu (until next reboot) by doing this:

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

I was hitting this issue on MacOS (Catalina), and disabling IPv6 solved it for me. (Thanks @stevegt for the previous answer pointing me in the right general direction.) I used this guide to disable IPv6 on my Mac; in my case the guide led me to this command:

networksetup -setv6off Wi-Fi
2

Pretty much what @stevegt suggested, please check his answer.

Now if you believe the issue is ipv6, run a quick test to confirm https://ipv6-test.com/.

If, indeed, you have an ipv6 problem it could be the case that your ISP does not support it, in which case please complain, don't let them get away with it.

In the meantime, you might want to disable ipv6 altogether on your machine to avoid this kind of problem (slow connection, etc). I would recommend you just disable it on the kernel at boot time by adding ipv6.disable=1 to the kernel parameters.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.