尝试在 Windows 10 机器和 python 3.7.2 中安装 python 包。我正在使用以下命令:
pip install numpy
它会永远挂起。我尝试使用以下方法获取更多信息:
pip -vvv install numpy
结果如下:
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
我试图研究它,但找不到任何东西。我不敢相信只有这个包会通过 HTTPS,这就是它失败的原因?
最佳答案
我对 Django 也有同样的问题。
两个命令的输出差异如下:
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>
使用 --no-cache-dir
只是绕过了这个问题。
当我手动删除缓存目录的内容时,解决方案就来了。
rm -Rf ~/.cache/pip/*
允许 pip install Django
按预期工作,缓存又开始自行重建。
来自docs您可以根据您的操作系统找到缓存所在的路径:
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
关于python - Pip 卡在 "collecting numpy",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54687610/