解决not a supported wheel on this platform-解决pip has no attribute pep425tags-解决网上旧教程不适用的问题

背景

今天在给树莓配安装tensorflow的使用,提示tensorflow-2.0.0-cp37-none-linux_armv7l.whl is not a supported wheel on this platform。
出现这个问题,是由于这个whl和系统python版本不匹配导致的,并介绍了如何查看当前python支持的版本。
然而,网上的教程非常老旧,按照网上教程操作后,会提示pip has no attribute pep425tags。经过我多次搜集资料和尝试,总算找到的在pip 20.0等版本上可用的命令!

1 已知无效的命令

首先列举在较新版本的pip中无效的命令。如果在较新版本的pip中使用这些命令,将会提示pip has no attribute pep425tags
无效旧教程一:

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

无效旧教程二:

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

上面为目前网上大量充斥的教程,这些均为旧版pip的教程并不适用于pip 20.0甚至临近版本
使用上述旧教程,会得到pip has no attribute pep425tags。如下图所示。
解决not a supported wheel on this platform-解决pip has no attribute pep425tags-解决网上旧教程不适用的问题_第1张图片
在此,经过博主大量搜集资料和尝试,终于找到了在pip 20.0版本上可用的方法。

2 经测试有效的命令

我们可以通过下面这个经过测试有效的命令,来查看当前Python版本匹配那些文件。
有效命令:

pip debug --verbose

输入这个命令后,会输出大量信息:

pip version: pip 20.1.1 from /home/pi/Softwares/venv3/lib/python3.7/site-packages/pip (python 3.7)
sys.version: 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0]
sys.executable: /home/pi/Softwares/venv3/bin/python
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: UTF-8
sys.platform: linux
sys.implementation:
name: cpython
‘cert’ config value: global
REQUESTS_CA_BUNDLE: None
CURL_CA_BUNDLE: None
pip._vendor.certifi.where(): /home/pi/Softwares/venv3/lib/python3.7/site-packages/pip/_vendor/certifi/cacert.pem
pip._vendor.DEBUNDLED: False
vendored library versions:
appdirs1.4.3
CacheControl
0.12.6
colorama0.4.3
contextlib2
0.6.0.post1 (Unable to locate actual module version, using vendor.txt specified version)
distlib0.3.0
distro
1.5.0 (Unable to locate actual module version, using vendor.txt specified version)
html5lib1.0.1
ipaddress
1.0.23
msgpack1.0.0 (Unable to locate actual module version, using vendor.txt specified version)
packaging
20.3
pep5170.8.2
progress
1.5
pyparsing2.4.7
requests
2.23.0
certifi2020.04.05.1
chardet
3.0.4
idna2.9
urllib3
1.25.8
resolvelib0.3.0
retrying
1.3.3 (Unable to locate actual module version, using vendor.txt specified version)
setuptools44.0.0 (Unable to locate actual module version, using vendor.txt specified version)
six
1.14.0
toml0.10.0
webencodings
0.5.1 (Unable to locate actual module version, using vendor.txt specified version)
Compatible tags: 44
cp37-cp37m-manylinux2014_armv7l
cp37-cp37m-linux_armv7l
cp37-abi3-manylinux2014_armv7l
cp37-abi3-linux_armv7l
cp37-none-manylinux2014_armv7l
cp37-none-linux_armv7l
cp36-abi3-manylinux2014_armv7l
cp36-abi3-linux_armv7l
cp35-abi3-manylinux2014_armv7l
cp35-abi3-linux_armv7l
cp34-abi3-manylinux2014_armv7l
cp34-abi3-linux_armv7l
cp33-abi3-manylinux2014_armv7l
cp33-abi3-linux_armv7l
cp32-abi3-manylinux2014_armv7l
cp32-abi3-linux_armv7l
py37-none-manylinux2014_armv7l
py37-none-linux_armv7l
py3-none-manylinux2014_armv7l
py3-none-linux_armv7l
py36-none-manylinux2014_armv7l
py36-none-linux_armv7l
py35-none-manylinux2014_armv7l
py35-none-linux_armv7l
py34-none-manylinux2014_armv7l
py34-none-linux_armv7l
py33-none-manylinux2014_armv7l
py33-none-linux_armv7l
py32-none-manylinux2014_armv7l
py32-none-linux_armv7l
py31-none-manylinux2014_armv7l
py31-none-linux_armv7l
py30-none-manylinux2014_armv7l
py30-none-linux_armv7l
cp37-none-any
py37-none-any
py3-none-any
py36-none-any
py35-none-any
py34-none-any
py33-none-any
py32-none-any
py31-none-any
py30-none-any

从中我们可以看到Compatible tags字样,这些就是当前Python版本可以适配的标签。例如,我的Python版本是3.7.3,可以匹配下面这些文件名:

Compatible tags: 44
cp37-cp37m-manylinux2014_armv7l
cp37-cp37m-linux_armv7l
cp37-abi3-manylinux2014_armv7l
cp37-abi3-linux_armv7l
cp37-none-manylinux2014_armv7l
cp37-none-linux_armv7l
cp36-abi3-manylinux2014_armv7l
cp36-abi3-linux_armv7l
cp35-abi3-manylinux2014_armv7l
cp35-abi3-linux_armv7l
cp34-abi3-manylinux2014_armv7l
cp34-abi3-linux_armv7l
cp33-abi3-manylinux2014_armv7l
cp33-abi3-linux_armv7l
cp32-abi3-manylinux2014_armv7l
cp32-abi3-linux_armv7l
py37-none-manylinux2014_armv7l
py37-none-linux_armv7l
py3-none-manylinux2014_armv7l
py3-none-linux_armv7l
py36-none-manylinux2014_armv7l
py36-none-linux_armv7l
py35-none-manylinux2014_armv7l
py35-none-linux_armv7l
py34-none-manylinux2014_armv7l
py34-none-linux_armv7l
py33-none-manylinux2014_armv7l
py33-none-linux_armv7l
py32-none-manylinux2014_armv7l
py32-none-linux_armv7l
py31-none-manylinux2014_armv7l
py31-none-linux_armv7l
py30-none-manylinux2014_armv7l
py30-none-linux_armv7l
cp37-none-any
py37-none-any
py3-none-any
py36-none-any
py35-none-any
py34-none-any
py33-none-any
py32-none-any
py31-none-any
py30-none-any

这是真正解决了网上旧教程无效的问题。使用于pip 20.0等新版本的pip。

3 注意

之前旧版本的无效命令是Python命令,而此次有效命令则是pip命令,直接在命令行中输入,不要在Python解释器中输入哦

你可能感兴趣的:(Python,python,pip)