module ‘pip‘ has no attribute ‘pep425tags‘的解决方案

module 'pip' has no attribute 'pep425tags'的解决方案

问题描述

在查看pip支持的文件名和版本时,常会提示module ‘pip’ has no attribute ‘pep425tags’,这主要是使用的pip版本的问题。

解决方法

win32常用:
import pip;
print(pip.pep425tags.get_supported())

amd64常用:

  1. import pip._internal
    print(pip._internal.pep425tags.get_supported())
  2. import pip._internal.pep425tags
  3. import wheel.pep425tags as w

但是这些在我的电脑上都不管用,有用的命令为在CMD执行:
python -m pip debug --verbose

运行结果

1
执行:import pip;
print(pip.pep425tags.get_supported())
输出:Traceback (most recent call last):
File “<pyshell#0>”, line 1, in
import pip; print(pip.pep425tags.get_supported())
AttributeError: module ‘pip’ has no attribute 'pep425tags’

>>> import pip;
>>> print(pip.pep425tags.get_supported())
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pip; print(pip.pep425tags.get_supported())
AttributeError: module 'pip' has no attribute 'pep425tags'

2
执行:import pip._internal.pep425tags
输出:Traceback (most recent call last):
File “<pyshell#1>”, line 1, in
import pip._internal.pep425tags
ModuleNotFoundError: No module named 'pip._internal.pep425tags’

>>> import pip._internal.pep425tags
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import pip._internal.pep425tags
ModuleNotFoundError: No module named 'pip._internal.pep425tags'

3
执行:import pip._internal; print(pip._internal.pep425tags.get_supported())
输出:Traceback (most recent call last):
File “<pyshell#3>”, line 1, in
print(pip._internal.pep425tags.get_supported())
AttributeError: module ‘pip._internal’ has no attribute 'pep425tags’

>>> import pip._internal
>>> print(pip._internal.pep425tags.get_supported())
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    print(pip._internal.pep425tags.get_supported())
AttributeError: module 'pip._internal' has no attribute 'pep425tags'

执行:import wheel.pep425tags as w
输出:Traceback (most recent call last):
File “<pyshell#4>”, line 1, in
import wheel.pep425tags as w
ModuleNotFoundError: No module named 'wheel’

>>> import wheel.pep425tags as w
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import wheel.pep425tags as w
ModuleNotFoundError: No module named 'wheel'

在我的电脑上可行的方法:
5
在CMD执行命令:python -m pip debug --verbose

C:\Users\zy>python -m pip debug --verbose
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
pip version: pip 20.2.2 from E:\python\lib\site-packages\pip (python 3.8)
sys.version: 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]
sys.executable: E:\python\python.exe
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: cp936
sys.platform: win32
sys.implementation:
  name: cpython
'cert' config value: Not specified
REQUESTS_CA_BUNDLE: None
CURL_CA_BUNDLE: None
pip._vendor.certifi.where(): E:\python\lib\site-packages\pip\_vendor\certifi\cacert.pem
pip._vendor.DEBUNDLED: False
vendored library versions:
  appdirs==1.4.4
  CacheControl==0.12.6
  colorama==0.4.3
  contextlib2==0.6.0.post1 (Unable to locate actual module version, using vendor.txt specified version)
  distlib==0.3.1
  distro==1.5.0 (Unable to locate actual module version, using vendor.txt specified version)
  html5lib==1.1
  ipaddress==1.0.23
  msgpack==1.0.0 (Unable to locate actual module version, using vendor.txt specified version)
  packaging==20.4
  pep517==0.8.2
  progress==1.5
  pyparsing==2.4.7
  requests==2.24.0
  certifi==2020.06.20
  chardet==3.0.4
  idna==2.10
  urllib3==1.25.9
  resolvelib==0.4.0
  retrying==1.3.3 (Unable to locate actual module version, using vendor.txt specified version)
  setuptools==44.0.0 (Unable to locate actual module version, using vendor.txt specified version)
  six==1.15.0
  toml==0.10.1
  webencodings==0.5.1 (Unable to locate actual module version, using vendor.txt specified version)
Compatible tags: 30
  cp38-cp38-win_amd64
  cp38-abi3-win_amd64
  cp38-none-win_amd64
  cp37-abi3-win_amd64
  cp36-abi3-win_amd64
  cp35-abi3-win_amd64
  cp34-abi3-win_amd64
  cp33-abi3-win_amd64
  cp32-abi3-win_amd64
  py38-none-win_amd64
  py3-none-win_amd64
  py37-none-win_amd64
  py36-none-win_amd64
  py35-none-win_amd64
  py34-none-win_amd64
  py33-none-win_amd64
  py32-none-win_amd64
  py31-none-win_amd64
  py30-none-win_amd64
  cp38-none-any
  py38-none-any
  py3-none-any
  py37-none-any
  py36-none-any
  py35-none-any
  py34-none-any
  py33-none-any
  py32-none-any
  py31-none-any
  py30-none-any

这就可以看到pip支持的文件名和版本了。

参考:
https://www.jianshu.com/p/dd8b4869d4fb

https://blog.csdn.net/qq_40772189/article/details/106455315

  • 100
    点赞
  • 162
    收藏
    觉得还不错? 一键收藏
  • 19
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 19
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值