Pip hangs on "collecting numpy"

I had the same issue with Django.

The diff in the output of both commands is the following:

pip install Django -vvv
...
Looking up "https://pypi.org/simple/django/" in the cache
Request header has "max_age" as 0, cache bypassed
https://pypi.org:443 "GET /simple/django/ HTTP/1.1" 304 0
<hangs here>

$ pip install Django --no-cache-dir -vvv
...
https://pypi.org:443 "GET /simple/django/ HTTP/1.1" 200 27460
<continues and successfully installs>

Using --no-cache-dir just bypasses the problem.

The solution came when I manually deleted the contents of the cache directory.

rm -Rf ~/.cache/pip/* allowed pip install Django to work as expected, and the cache started rebuilding itself again.

From the docs you can find the path where the cache lives, based on your os:

The default location for the cache directory depends on the Operating System:

Unix

~/.cache/pip and it respects the XDG_CACHE_HOME directory.

macOS

~/Library/Caches/pip.

Windows

<CSIDL_LOCAL_APPDATA>\pip\Cache


Yo can try adding:

--no-cache-dir

By default, when making any HTTP request pip will first check its local cache to determine if it has a suitable response stored for that request which has not expired. If the error comes in that part of the process, skipping that cache check should fix the problem.

Details in the official pip documentation.