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

混淆的一个来源是,当(例如)你执行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

这是怎么回事?

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

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


当前回答

错误:

系统: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

希望这能有所帮助

其他回答

在我的例子中,在创建venv后更新pip versión,这将pip从9.0.1更新到20.3.1

python3 -m venv env/python
source env/python/bin/activate
pip3 install pip --upgrade

但是,信息是…

Using legacy 'setup.py install' for django-avatar, since package 'wheel' is not installed.

然后,我在更新pip后安装车轮包

python3 -m venv env/python
source env/python/bin/activate
pip3 install --upgrade pip
pip3 install wheel

信息是…

Building wheel for django-avatar (setup.py): started
default:   Building wheel for django-avatar (setup.py): finished with status 'done'

错误:

系统: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

希望这能有所帮助

当您没有wheel所需的包时,通常会出现此错误。 如果您正在使用python3,则安装python3-dev或python2-dev(如果您正在使用python2)。

sudo apt-get install python3-dev 

or

sudo apt-get install python2-dev

昨天,我得到了同样的错误:当我运行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"

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

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

sudo apt install python3-pip -y

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

sudo pip3 install <package>