在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
这里发生了什么?
(我想了解如何发生某些故障但仍然可以安装,以及是否可以信任此软件包正常运行?)
到目前为止,我已经找到了最好的部分原因是这个。
pip
找不到所需的车轮时,它将下载源dist并尝试从本地构建一个车轮。成功完成后,轮子将存储在pip
的缓存中,以供将来重新安装。如果车轮制造失败,请pip
从源dist(调用python setup.py install
)切换到旧版安装。