模块“pip”没有属性“pep425tags”

2024-02-07

当我尝试使用 pip 安装 .whl 时

it said:

... is not a supported wheel on this platform

为了解决这个问题,我在网上搜索了一下,说我可以将这个输入到repl中

import pip; print(pip.pep425tags.get_supported())

这样我可以看到 pip 支持的标签和版本

然而,当我输入这段代码时,它说:

AttributeError: module 'pip' has no attribute 'pep425tags'

怎么了?

(Python 3.6 上的 pip 10.0.1)


打印与当前版本兼容的标签列表pip :

$ path/to/pythonX.Y -m pip debug --verbose

The pip debug https://pip.pypa.io/en/stable/cli/pip_debug/子命令可用v19.2 https://pip.pypa.io/en/stable/news/#v19-2(2019 年 7 月)。


要从 Python 代码中获取兼容标签的列表,我建议使用packaging library https://pypi.org/project/packaging/和它的packaging.tags.sys_tags()功能 https://packaging.pypa.io/en/stable/tags.html#packaging.tags.sys_tags:

import packaging.tags

tags = packaging.tags.sys_tags()

print('\n'.join([f'{tag.interpreter}-{tag.abi}-{tag.platform}' for tag in tags]))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

模块“pip”没有属性“pep425tags” 的相关文章

随机推荐