问题:pip安装中“ X的构建车轮失败”是什么意思?

在SO上,这是一个真正流行的问题,但是我看过的所有答案中,没有一个能清楚地说明此错误的真正含义以及发生的原因。

造成混乱的原因之一是,当您(例如)这样做时pip install pycparser,您首先会得到以下错误:

Failed building wheel for pycparser

然后出现以下消息,说明该软件包是:

Successfully installed pycparser-2.19


# pip3 install pycparser

Collecting pycparser
  Using cached https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz
Building wheels for collected packages: pycparser
  Running setup.py bdist_wheel for pycparser ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-g_v28hpp/pycparser/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-__w_f6p0 --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ...
    File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2349, in resolve
      module = __import__(self.module_name, fromlist=['__name__'], level=0)
  ModuleNotFoundError: No module named 'wheel.bdist_wheel'

  ----------------------------------------
  Failed building wheel for pycparser
  Running setup.py clean for pycparser
Failed to build pycparser
Installing collected packages: pycparser
  Running setup.py install for pycparser ... done
Successfully installed pycparser-2.19

这里发生了什么?

(我想了解如何发生某些故障但仍然可以安装,以及是否可以信任此软件包正常运行?)

到目前为止,我已经找到了最好的部分原因是这个

This is a truly popular question here at SO, but none of the many answers I have looked at, clearly explain what this error really mean, and why it occurs.

One source of confusion, is that when (for example) you do pip install pycparser, you first get the error:

Failed building wheel for pycparser

which is then followed by the message that the package was:

Successfully installed pycparser-2.19.


# pip3 install pycparser

Collecting pycparser
  Using cached https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz
Building wheels for collected packages: pycparser
  Running setup.py bdist_wheel for pycparser ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-g_v28hpp/pycparser/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-__w_f6p0 --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ...
    File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2349, in resolve
      module = __import__(self.module_name, fromlist=['__name__'], level=0)
  ModuleNotFoundError: No module named 'wheel.bdist_wheel'

  ----------------------------------------
  Failed building wheel for pycparser
  Running setup.py clean for pycparser
Failed to build pycparser
Installing collected packages: pycparser
  Running setup.py install for pycparser ... done
Successfully installed pycparser-2.19

What is going on here?

(I would like to understand how something can fail but still get installed and whether you can trust this package functioning correctly?)

So far the best partial explanation I have found is this.


回答 0

(这里是点子维护者!)

如果包装不是车轮,则pip尝试为其构建一个车轮(通过setup.py bdist_wheel)。如果由于任何原因导致安装失败,您将收到“ pycparser的建筑轮子故障”消息,并且pip退回到直接安装(通过setup.py install)。

装好轮子后,pip可以通过正确打开包装来安装轮子。pip尝试尽可能多地通过轮子安装软件包。这是由于使用滚轮的各种优势(例如更快的安装,可缓存的,不再执行代码等)。


您在这里的错误消息是由于wheel缺少软件包,其中包含构建轮子所需的逻辑setup.py bdist_wheel。(pip install wheel可以解决该问题。)


以上是当前默认的旧行为;我们会默认在将来的某个时间切换到PEP 517,为此我们将转到基于标准的流程。我们还为此提供了隔离的版本,因此,默认情况下,您会在这些环境中安装滚轮。:)

(pip maintainer here!)

If the package is not a wheel, pip tries to build a wheel for it (via setup.py bdist_wheel). If that fails for any reason, you get the “Failed building wheel for pycparser” message and pip falls back to installing directly (via setup.py install).

Once we have a wheel, pip can install the wheel by unpacking it correctly. pip tries to install packages via wheels as often as it can. This is because of various advantages of using wheels (like faster installs, cache-able, not executing code again etc).


Your error message here is due to the wheel package being missing, which contains the logic required to build the wheels in setup.py bdist_wheel. (pip install wheel can fix that.)


The above is the legacy behavior that is currently the default; we’ll switch to PEP 517 by default, sometime in the future, moving us to a standards-based process for this. We also have isolated builds for that so, you’d have wheel installed in those environments by default. :)


回答 1

昨天,我遇到了同样的错误: Failed building wheel for hddfancontrol跑步时pip3 install hddfancontrol。结果是Failed to build hddfancontrol。原因是error: invalid command 'bdist_wheel'Running setup.py bdist_wheel for hddfancontrol ... error。通过运行以下命令修复了该错误:

 pip3 install wheel

(从这里开始。)

另外,也可以从此处直接下载“ wheel” 。下载后,可以通过运行以下命令进行安装:

pip3 install "/the/file_path/to/wheel-0.32.3-py2.py3-none-any.whl"

Yesterday, I got the same error: Failed building wheel for hddfancontrol when I ran pip3 install hddfancontrol. The result was Failed to build hddfancontrol. The cause was error: invalid command 'bdist_wheel' and Running setup.py bdist_wheel for hddfancontrol ... error. The error was fixed by running the following:

 pip3 install wheel

(From here.)

Alternatively, the “wheel” can be downloaded directly from here. When downloaded, it can be installed by running the following:

pip3 install "/the/file_path/to/wheel-0.32.3-py2.py3-none-any.whl"

回答 2

从那以后,似乎没有人提到我自己。我自己解决上述问题是最常见的,以确保禁用缓存使用副本:pip install <package> --no-cache-dir

Since, nobody seem to mention this apart myself. My own solution to the above problem is most often to make sure to disable the cached copy by using: pip install <package> --no-cache-dir.


回答 3

从程序包部署的角度解决此问题可能会有所帮助。

那里有许多教程介绍了如何将程序包发布到PyPi。以下是我使用过的几对;

中型
真正的python

我的经验是,这些教程大多数都只使用源代码的.tar,而不使用转盘。因此,在安装使用这些教程创建的软件包时,我收到了“无法构建轮子”错误。

后来我在PyPi上找到了指向Python软件基金会的文档PSF Docs的链接。我发现它们的设置和构建过程略有不同,并且确实包括构建wheel文件。

使用正式记录的方法后,安装软件包时不再收到错误。

因此,错误可能只是开发人员如何打包和部署项目的问题。我们当中没有一个人天生就知道如何使用PyPi,如果它们是在错误的教程上发生的,那么您可以填补空白。

我敢肯定这不是错误的唯一原因,但我敢打赌这是主要原因。

It might be helpful to address this question from a package deployment perspective.

There are many tutorials out there that explain how to publish a package to PyPi. Below are a couple I have used;

medium
real python

My experience is that most of these tutorials only have you use the .tar of the source, not a wheel. Thus, when installing packages created using these tutorials, I’ve received the “Failed to build wheel” error.

I later found the link on PyPi to the Python Software Foundation’s docs PSF Docs. I discovered that their setup and build process is slightly different, and does indeed included building a wheel file.

After using the officially documented method, I no longer received the error when installing my packages.

So, the error might simply be a matter of how the developer packaged and deployed the project. None of us were born knowing how to use PyPi, and if they happened upon the wrong tutorial — well, you can fill in the blanks.

I’m sure that is not the only reason for the error, but I’m willing to bet that is a major reason for it.


回答 4

试试这个:

sudo apt-get install libpcap-dev libpq-dev

当我安装了这两个时,它对我有用。

有关更多信息,请参见此处的链接。

Try this:

sudo apt-get install libpcap-dev libpq-dev

It has worked for me when I have installed these two.

See the link here for more information


回答 5

在Ubuntu 18.04上,我遇到了此问题,因为的apt软件包wheel不包含wheel命令。我认为pip尝试导入wheelpython包,如果成功,则假定wheel命令也可用。Ubuntu打破了这一假设。

apt python3代码包的名称为python3-wheel。这是自动安装的,因为python3-pip建议您这样做。

apt python3 wheel命令包的名称为python-wheel-common。安装此工具也可以为我解决“建筑轮子故障”错误。

On Ubuntu 18.04, I ran into this issue because the apt package for wheel does not include the wheel command. I think pip tries to import the wheel python package, and if that succeeds assumes that the wheel command is also available. Ubuntu breaks that assumption.

The apt python3 code package is named python3-wheel. This is installed automatically because python3-pip recommends it.

The apt python3 wheel command package is named python-wheel-common. Installing this too fixes the “failed building wheel” errors for me.


回答 6

当我尝试安装pip install django-imagekit时,出现了相同的消息。因此,我运行了pip install wheel(我安装了python 2.7),然后重新运行了pip install django-imagekit,它开始工作了。谢谢

I got the same message when I tried to install pip install django-imagekit. So I ran pip install wheel (I had python 2.7) and then I reran pip install django-imagekit and it worked. Thanks


回答 7

我想补充一点,如果您的系统上只有Python3,则需要开始使用pip3而不是pip。

您可以使用以下命令安装pip3;

sudo apt install python3-pip -y

之后,您可以尝试安装所需的软件包。

sudo pip3 install <package>

I would like to add that if you only have Python3 on your system then you need to start using pip3 instead of pip.

You can install pip3 using the following command;

sudo apt install python3-pip -y

After this you can try to install the package you need with;

sudo pip3 install <package>

回答 8

错误:

系统:AWS EC2实例(T2小)

问题:通过安装opencv python时

pip3 install opencv-python

  Problem with the CMake installation, aborting build. CMake executable is cmake
  
  ----------------------------------------
  Failed building wheel for opencv-python
  Running setup.py clean for opencv-python

什么对我有用

pip3 install --upgrade pip setuptools wheel

在此之后,您仍然可能会收到休闲错误错误

    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

安装libgl为我解决了错误。

sudo apt update
sudo apt install libgl1-mesa-glx

希望这可以帮助

Error :

System : aws ec2 instance (t2 small)

issue : while installing opencv python via

pip3 install opencv-python

  Problem with the CMake installation, aborting build. CMake executable is cmake
  
  ----------------------------------------
  Failed building wheel for opencv-python
  Running setup.py clean for opencv-python

What worked for me

pip3 install --upgrade pip setuptools wheel

After this you still might received fallowing error error

    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Installing libgl solved the error for me.

sudo apt update
sudo apt install libgl1-mesa-glx

Hope this helps


回答 9

安装Brotli时遇到相同的问题

错误

Failed building wheel for Brotli

我通过.whl此处下载文件 并使用以下命令进行安装来解决了该问题

C:\Users\{user_name}\Downloads>pip install Brotli-1.0.9-cp39-cp39-win_amd64.whl

I had the same problem while installing Brotli

ERROR

Failed building wheel for Brotli

I solved it by downloading the .whl file from here and installing it using the below command

C:\Users\{user_name}\Downloads>pip install Brotli-1.0.9-cp39-cp39-win_amd64.whl

回答 10

这可能对您有帮助!….

卸载pycparser:

pip uninstall pycparser

重新安装pycparser:

pip install pycparser

我在安装termcolor时遇到了同样的错误,并通过重新安装进行了修复。

This may Help you ! ….

Uninstalling pycparser:

pip uninstall pycparser

Reinstall pycparser:

pip install pycparser

I got same error while installing termcolor and I fixed it by reinstalling it .


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。