Python 语法问题-module ‘pip._internal‘ has no attribute ‘pep425tags‘. 原因及解决办法,32位、64位查看pip支持万能方法

2020-09-23 14:46:19 浏览数 (1)

方法一:新方法篇

直接用pip debug --verbose 命令即可看 pip 支持。 注: 感谢 lukea 小伙伴的分享!

详细代码如下:

代码语言:javascript复制
C:UsersAdministrator>pip debug --verbose
WARNING: This command is only meant for debugging. Do not use this with automati
on for parsing and getting these details, since the output and options of this c
ommand may change without notice.
pip version: pip 20.0.2 from d:pythonlibsite-packagespip (python 3.6)
sys.version: 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit
 (Intel)]
sys.executable: d:pythonpython.exe
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: cp936
sys.platform: win32
sys.implementation:
  name: cpython
'cert' config value: install
REQUESTS_CA_BUNDLE: None
CURL_CA_BUNDLE: None
pip._vendor.certifi.where(): d:pythonlibsite-packagespip_vendorcertificac
ert.pem
Compatible tags: 24
  cp36-cp36m-win32
  cp36-abi3-win32
  cp36-none-win32
  cp35-abi3-win32
  cp34-abi3-win32
  cp33-abi3-win32
  cp32-abi3-win32
  py36-none-win32
  py3-none-win32
  py35-none-win32
  py34-none-win32
  py33-none-win32
  py32-none-win32
  py31-none-win32
  py30-none-win32
  cp36-none-any
  py36-none-any
  py3-none-any
  py35-none-any
  py34-none-any
  py33-none-any
  py32-none-any
  py31-none-any
  py30-none-any

方法二:常规方法篇

64 位 pip 老的查看方法前段时间更新后就不能用了。 之前导入pip._internal就好了。 现在需要导入 pip._internal.pep425tags 才可以。

代码语言:javascript复制
>>> import pip._internal.pep425tags
>>> print(pip._internal.pep425tags.get_supported())
[('cp36', 'cp36m', 'win32'), ('cp36', 'none', 'win32'), ('py3', 'none', 'win32')
, ('cp36', 'none', 'any'), ('cp3', 'none', 'any'), ('py36', 'none', 'any'), ('py
3', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', '
none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none'
, 'any')]
>>>

方法三:万能方法

我们直接在 pip 里搜 pep425tags.py 这个文件就行,找到它的位置。 一般导入报错就说明位置不对,每个版本都可能有一些差异,位置可能有变化。 我下载了个 32 位的,查找发现了它的位置,然后直接导入它就行了。

代码语言:javascript复制
>>> import pip._internal.pep425tags as e
>>> print(e.get_supported())
[<cp36-cp36m-win32 @ 36751360>, <cp36-abi3-win32 @ 36751040>, <cp36-none-win32 @
 36751080>, <cp35-abi3-win32 @ 36752000>, <cp34-abi3-win32 @ 36752200>, <cp33-ab
i3-win32 @ 40114816>, <cp32-abi3-win32 @ 40114856>, <py36-none-win32 @ 40114936>
, <py3-none-win32 @ 40114976>, <py35-none-win32 @ 40115016>, <py34-none-win32 @
40115056>, <py33-none-win32 @ 40115096>, <py32-none-win32 @ 40115136>, <py31-non
e-win32 @ 40115176>, <py30-none-win32 @ 40115216>, <cp36-none-any @ 40115256>, <
py36-none-any @ 40115296>, <py3-none-any @ 40115336>, <py35-none-any @ 40115376>
, <py34-none-any @ 40115416>, <py33-none-any @ 40115456>, <py32-none-any @ 40115
536>, <py31-none-any @ 40115576>, <py30-none-any @ 40115616>]

0 人点赞