Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip hangs on "collecting numpy"

Trying to install packages for python in Windows 10 machine and python 3.7.2. I'm using the following command:

pip install numpy

And it hangs forever. I tried to get more information using the following:

pip -vvv install numpy

and here's the result:

Collecting numpy
  1 location(s) to search for versions of numpy:
  * https://pypi.org/simple/numpy/
  Getting page https://pypi.org/simple/numpy/
  Looking up "https://pypi.org/simple/numpy/" in the cache
  Request header has "max_age" as 0, cache bypassed
  Starting new HTTPS connection (1): pypi.org:443
  https://pypi.org:443 "GET /simple/numpy/ HTTP/1.1" 304 0

I tried to research it but can't find anything. I can't believe only this package would go through HTTPS and that's why it's failing?

like image 659
Moseleyi Avatar asked Feb 14 '19 09:02

Moseleyi


1 Answers

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

like image 174
raratiru Avatar answered Sep 19 '22 11:09

raratiru