1. 程式人生 > 其它 >【轉】檢視python支援whl名稱的方法

【轉】檢視python支援whl名稱的方法

背景

今天在給樹莓配安裝tensorflow的時候,提示tensorflow-2.0.0-cp37-none-linux_armv7l.whl is not a supported wheel on this platform。
出現這個問題,是由於這個whl和系統python版本不匹配導致的。這個時候,需要我們找到當前python版本需要的whl命名格式,網上有不少教程提供了檢視python支援whl名稱的方法。
然而,網上的教程非常老舊,按照網上教程操作後,會提示pip has no attribute pep425tags。經過我多次蒐集資料和嘗試,總算找到了在pip 20.0等版本上可用的命令!

經測試有效的命令

我們可以通過下面這個經過測試有效的命令,來檢視當前Python版本匹配那些檔案。
有效命令如下(直接在命令列中輸入,不要在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
CacheControl0.12.6
colorama0.4.3
contextlib20.6.0.post1 (Unable to locate actual module version, using vendor.txt specified version)
distlib0.3.0
distro1.5.0 (Unable to locate actual module version, using vendor.txt specified version)
html5lib1.0.1
ipaddress1.0.23
msgpack1.0.0 (Unable to locate actual module version, using vendor.txt specified version)
packaging20.3
pep5170.8.2
progress1.5
pyparsing2.4.7
requests2.23.0
certifi2020.04.05.1
chardet3.0.4
idna2.9
urllib31.25.8
resolvelib0.3.0
retrying1.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)
six1.14.0
toml0.10.0
webencodings0.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。

注意

之前舊版本的無效方法是Python語句,而此次有效命令則是pip命令,直接在命令列中輸入,不要在Python直譯器中輸入哦
在找到python支援的標籤後,就去下載對應的版本來安裝吧~