这是一个非常受欢迎的问题,但我所看到的许多答案中,没有一个能清楚地解释这个错误的真正含义,以及它为什么会发生。

混淆的一个来源是,当(例如)你执行pip install pycparser时,你首先得到错误:

pycparser构建转轮失败

后面跟着一个消息,这个包是:

成功安装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

这是怎么回事?

(我想了解一些东西是如何失败的,但仍然可以安装,以及您是否可以相信这个包正常运行?)

到目前为止,我找到的最好的部分解释是这样的。


当前回答

昨天,我得到了同样的错误:当我运行pip3安装hddfancontrol时,未能为hddfancontrol构建轮子。日志含义Failed to build hddfancontrol。原因是错误:无效命令'bdist_wheel'和运行setup.py bdist_wheel for hddfancontrol…错误。通过运行以下命令修复了错误:

 pip3 install wheel

(从这儿)。

或者,“轮子”可以直接从这里下载。下载后,可以通过运行以下命令进行安装:

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

其他回答

从那以后,除了我自己,似乎没有人提起这件事。对于上述问题,我自己的解决方案通常是通过使用pip install <package>——no-cache-dir来确保禁用缓存副本。

错误:

系统:aws ec2实例(t2小)

问题:在安装opencv python via

Pip3安装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安装——升级PIP setuptools轮

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

    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

希望这能有所帮助

当我试图安装一个需要'isal'的包时,我被这个问题困扰了几个小时,但isal安装失败了:

  ----------------------------------------
  ERROR: Failed building wheel for isal
Failed to build isal
ERROR: Could not build wheels for isal which use PEP 517 and cannot be installed directly

适合我的解决方案是安装libtool。

yum install libtool

(pip维护者在这里!)

快速复制粘贴:

pip install wheel

在用venv创建的每个新虚拟环境中都这样做。

继续阅读,了解细节和解释。


如果包不是一个轮子,pip会试着为它构建一个轮子(通过setup.py bdist_wheel)。如果因为任何原因失败了(比如,缺少系统级库,与系统不兼容,所构建的轮中的错误版本字符串,等等),你会得到“{…}”消息。

在其中一些情况下,目前pip通过setup.py install返回到安装,因此安装仍然有可能成功。也就是说,pip总是尽可能多地尝试通过轮子安装包。这是因为使用轮子的各种优势(如更快的安装,可缓存,无需再次执行代码等)以及它是标准化格式的事实;不像(已弃用的)setup.py安装界面。


这里的错误消息是由于缺少wheel包,其中包含在setup.py bdist_wheel中构建轮子所需的逻辑。(pip安装轮可以修复这个问题——但它不会修复由于系统配置而导致的任何构建时间问题)


在将来的某个时候,我们将在默认情况下切换到一个更现代的构建系统(如果您是一个包作者,您可以通过添加pyproject.toml来选择加入),通过隔离的构建环境来解决这个问题,您将在其中安装wheel。:)

PEP 517:源代码树的独立于构建系统的格式 一篇关于“PEP 517和518简明英语”的博客文章

我试着安装的时候也收到了同样的信息

pip install django-imagekit. 

所以我跑了

pip install wheel 

(我有python 2.7),然后我重新运行pip安装django-imagekit,它工作了。