我确定这不是网络问题。我的一些机器使用 pip 安装软件包非常快,而其他一些机器则相当慢,从日志来看,我怀疑缓慢是因为它会编译软件包,我想知道如何避免这种编译来进行 pip 安装快速地。这是慢速 pip 安装的日志。
Collecting numpy==1.10.4 (from -r requirements.txt (line 1))
Downloading numpy-1.10.4.tar.gz (4.1MB)
100% |████████████████████████████████| 4.1MB 95kB/s
Requirement already satisfied (use --upgrade to upgrade): wheel==0.26.0 in ./lib/python2.7/site-packages (from -r requirements.txt (line 2))
Building wheels for collected packages: numpy
Running setup.py bdist_wheel for numpy ... -
done
Stored in directory: /root/.cache/pip/wheels/66/f5/d7/f6ddd78b61037fcb51a3e32c9cd276e292343cdd62d5384efd
Successfully built numpy
缓慢确实是由于编译造成的。但现在有了 manylinux 标签。它允许安装预编译的发行版。例如,请参阅 numpy 的 PyPI 页面,查看是否为您的 Python 版本提供了 Manylinux 软件包。
由于这个答案最近受到了一些关注,现在有很多manylinux标签用于预编译包(没有双关语)。
对我来说,我在 pip 22.0.4、Ubuntu 20.04.4 LTS 中遇到了这个问题。 我正在安装tensorflow-gpu,这已经花费了太多时间,但是pip异常慢。 上述解决方案对我来说没有任何意义,所以我执行了以下操作:
我知道这似乎不是一个永久的解决方案,但它解决了我的问题。
如果您使用的是 Anaconda,请尝试更新 pip,这为我解决了问题。