![安装 Python 版 OpenEXR 会导致 setuptools 失败并出现断言错误](https://linux22.com/image/1014319/%E5%AE%89%E8%A3%85%20Python%20%E7%89%88%20OpenEXR%20%E4%BC%9A%E5%AF%BC%E8%87%B4%20setuptools%20%E5%A4%B1%E8%B4%A5%E5%B9%B6%E5%87%BA%E7%8E%B0%E6%96%AD%E8%A8%80%E9%94%99%E8%AF%AF.png)
我正在尝试安装一个将 OpenEXR 绑定添加到 python 的包: https://github.com/jamesbowman/openexrpython
但是,当我通过在项目目录中执行来运行 setuptools 时pip install .
,我收到一个奇怪的错误,这似乎是由于 python 核心包中的内部拼写错误造成的:
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
copying build/lib.linux-x86_64-3.7/OpenEXR.cpython-@PYVERNODOTS@m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/wheel
copying build/lib.linux-x86_64-3.7/Imath.py -> build/bdist.linux-x86_64/wheel
running install_egg_info
running egg_info
creating OpenEXR.egg-info
writing OpenEXR.egg-info/PKG-INFO
writing dependency_links to OpenEXR.egg-info/dependency_links.txt
writing top-level names to OpenEXR.egg-info/top_level.txt
writing manifest file 'OpenEXR.egg-info/SOURCES.txt'
reading manifest file 'OpenEXR.egg-info/SOURCES.txt'
writing manifest file 'OpenEXR.egg-info/SOURCES.txt'
Copying OpenEXR.egg-info to build/bdist.linux-x86_64/wheel/OpenEXR-1.3.2-py3.7.egg-info
running install_scripts
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-rsemsxrd/setup.py", line 25, in <module>
py_modules=['Imath'],
File "/home/james/anaconda3/envs/exrtest/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/james/anaconda3/envs/exrtest/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/james/anaconda3/envs/exrtest/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/james/anaconda3/envs/exrtest/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 230, in run
impl_tag, abi_tag, plat_tag = self.get_tag()
File "/home/james/anaconda3/envs/exrtest/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 179, in get_tag
assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0])
AssertionError: ('cp37', 'cp@pyvernodots@m', 'linux_x86_64') != ('cp37', 'cp@PYVERNODOTS@m', 'linux_x86_64')
----------------------------------------
ERROR: Failed building wheel for OpenEXR
如您所见,原因是断言错误,该断言错误正在检查两组标签是否匹配,但由于比较的两个字符串是'cp@pyvernodots@m'
和,因此失败'cp@PYVERNODOTS@m'
。显然,这两个字符串应该是等价的,但由于错误,其中一个字符串的大小写错误。我对 python 包管理系统的内部结构了解不够,无法理解这些字符串的确定位置以及如何修复它们。我能找到的唯一相关资源是有关兼容性标签的这份文档,显然这些标签导致了此故障:https://www.python.org/dev/peps/pep-0425/。
我的python版本是3.7.4,使用anaconda安装,并且这是在全新环境中完成的。
答案1
我在安装完全不同的软件包时遇到了这个问题。这似乎是 Python 发行版的问题。我使用 conda 安装的 Python 3.7.4 遇到了问题。使用 Python 3.7.3 创建环境解决了我的问题。你可以这样做:
conda create -n myenv python=3.7.3
编辑:正如@frmdstryr 在评论中指出的那样,这个问题现在已得到解决。现在应该不再需要降级了。请参阅评论以获取指向(现已关闭的)github 问题的链接。