[英]When does "pip install" build a wheel?
I found that in different folders, sometimes pip install
will build wheel which takes a lot of time, while sometimes it doesn't.我发现在不同的文件夹中,有时
pip install
会构建轮子,这会花费很多时间,而有时则不会。 I'm not sure why and how to control that.我不确定为什么以及如何控制它。
My command: bin/python -m pip install -r ../requirements.txt
(due to the !#
shebang line-length limitation, so I don't use pip directly)我的命令:
bin/python -m pip install -r ../requirements.txt
(由于!#
shebang line-length 限制,所以我不直接使用 pip)
The output without building a wheel (just takes a few seconds):无需构建轮子的输出(只需几秒钟):
Collecting numpy==1.10.4 (from -r ../requirements.txt (line 1))
Installing collected packages: numpy
Successfully installed numpy-1.10.4
The output with building wheel (take at least 2 minutes)带构建轮的输出(至少需要 2 分钟)
Collecting numpy==1.10.4 (from -r ../requirements.txt (line 1))
Downloading numpy-1.10.4.tar.gz (4.1MB)
100% |████████████████████████████████| 4.1MB 92kB/s
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
Installing collected packages: numpy
Successfully installed numpy-1.10.4
The contents of requirements.txt
: requirements.txt
的内容:
numpy==1.10.4
Today I encountered a problem where a package wasn't being installed properly because it turns out that its build process generates incorrect wheel packages, even though direct installation works just fine.今天我遇到了一个包没有正确安装的问题,因为它的构建过程生成了不正确的轮包,即使直接安装也很好。
I did a bit of poking around, and it turns out that as of now ( pip == 8.1.2
), there isn't a direct way to control whether or not pip
will try to build a wheel out of a given package.我做了一些探索,结果发现到目前为止(
pip == 8.1.2
),没有直接的方法来控制pip
是否会尝试从给定的包中构建一个轮子。 I found the relevant source code , and apparently, the wheel build process is used if and only if:我找到了相关的源代码,显然,当且仅当:
As a result of that logic, one can indirectly disable pip's use of wheel-based builds by passing --no-cache-dir
on the install command line.由于该逻辑,可以通过在安装命令行上传递
--no-cache-dir
来间接禁用 pip 对基于轮的构建的使用。
This depends on whether your package is a pure python package (without the need to compile anything, just copy the files somewhere) or a package which also includes c source code (in which case a compilation is necessary and a compiler is called and executed, which takes longer).这取决于您的包是纯 python 包(无需编译任何东西,只需将文件复制到某处)还是还包含 c 源代码的包(在这种情况下需要编译并调用并执行编译器,这需要更长的时间)。
http://pythonwheels.com/ http://pythonwheels.com/
You may also want to have a look at the wheel docu:您可能还想看看轮文档:
http://wheel.readthedocs.org/en/latest/ http://wheel.readthedocs.org/en/latest/
我得到了答案,这只是第一次构建轮子,之后它将从缓存中读取
When I install slither-analyzer
using pip3
on my Mac, I got a similar error.当我在我的 Mac 上使用
pip3
安装滑行slither-analyzer
时,我遇到了类似的错误。
Building wheels for collected packages: pysha3
Building wheel for pysha3 (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
The solution is to reinstall your Xcode tools.解决方案是重新安装 Xcode 工具。
$ xcode-select --install
$ xcode-select --reset
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.