Pip hangs on "collecting numpy"
Solution 1
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
Solution 2
IPv6 somehow caused this problem for me. After disabling ipv6 networking on my device, the command went through fine!
Solution 3
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.
Solution 4
As a workaround, you could manually download and install numpy
Go to here and choose the .whl file of the version you'd like installed: https://pypi.org/simple/numpy/
Once it's downloaded you can manually install the .whl:
pip install numpy-1.16.1-cp37-cp37m-win_amd64.whl
Related videos on Youtube
Moseleyi
Interested in SQL, MySQL, PostgreSQL STATA, R Social Sciences, Data Collection & Analysis for NGO Sector Monitoring & Evaluation, Partner Assessments Google Sheets & Microsoft Excel Salesforce (including Administration, Data Migration) Database administration
Updated on June 28, 2022Comments
-
Moseleyi almost 2 years
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?
-
Moseleyi over 5 yearsCan you elaborate why it would make a difference?
-
Alex Yu over 5 yearsHttp 304 means "Not Modified". I did not look into source of pip but it's possible that package in cache prevents installation
-
Moseleyi over 5 yearsIt worked but it wouldn't work with a file of packages to install. For example this:
pip install -r req.txt
had packagepandas
which hasnumpy
as dependency. Adding--no-cache-dir
didnt' work there and it still hung but it worked when I install numpy on its own -
Moseleyi about 5 yearsThat's true, it just bypasses the problem. I still haven't found a long-term solution
-
raratiru about 5 years@Moseleyi In my case, when I deleted the cache
rm -Rf ~/.cache/pip/*
,pip install Django
started working without--no-cache-dir
and the cache started to rebuild again. -
Moseleyi about 5 yearshm but how can this be automated? We have a text file called
requirements
with list of packages to install. I'm not sure I can incpororate this in such script? -
raratiru about 5 years@Moseleyi Oh, no, I did it once manually. When the contents of the cache were removed along with the content that caused pip to freeze hanging unable to do anything,
pip install -r requirements.txt
is "forever" working as expected without modifications, without--no-cache-dir
. -
raratiru about 5 years
-
Moseleyi about 5 yearsIt worked, I deleted the folder and everything went smoothly. Needed to install some C++ Compiler and that's it. Then added everything to the Path and finally it worked! :D