Python 安装库文件 is not a supported wheel on this platform的解决方案
Python 安装库文件 is not a supported wheel on this platform的解决办法
1 问题描述
本人最近安装python版的GDAL库,下载的版本为GDAL-3.1.2-cp39-cp39-win_amd64.whl
CMD执行命令:pip install GDAL-3.1.2-cp39-cp39-win_amd64.whl
却出现错误提示:
ERROR: GDAL-3.1.2-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.
E:\python\Lib\site-packages>pip install GDAL-3.1.2-cp39-cp39-win_amd64.whl
ERROR: GDAL-3.1.2-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.
如下图:
2 问题原因分析
出现这一问题的原因主要分为两种:
- 安装的不是对应python版本的库,下载的库名中cp39代表python3.9,而我安装的python版本是3.8.5。
- 下载的是对应版本的库,然后仍然提示不支持当前平台。
3 解决方案
解决这类问题,要保证自己安装的库对应于安装的python版本及当前平台。
3.1 获取pip支持的文件名和版本
在网上搜索到的查看pip支持的文件名和版本的命令及自己的运行结果(在自己的电脑上不可行)分别是:
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支持的文件名和版本,最高版本为 cp38-cp38-win_amd64,而之前安装的是cp39-cp39-win_amd64。
3.2 下载特定版本的库
可以看到,我的pip支持cp38-cp38-win_amd64,恰好有这个版本的GDAL文件GDAL-3.1.2-cp38-cp38-win_amd64.whl
于是下载该版本的文件
3.3 安装
CMD执行命令:pip install GDAL-3.1.2-cp38-cp38-win_amd64.whl
E:\python\Lib\site-packages>pip install GDAL-3.1.2-cp38-cp38-win_amd64.whl
Processing e:\python\lib\site-packages\gdal-3.1.2-cp38-cp38-win_amd64.whl
Installing collected packages: GDAL
Successfully installed GDAL-3.1.2
至此,成功安装了python版本的GDAL库。
4 其他解决方案
在看到自己电脑上pip支持的文件名和版本后,也有人说可以直接修改下载的文件名,但个人并不建议这样做。
本文地址:https://blog.csdn.net/weixin_44035267/article/details/108256335
推荐阅读
-
Python使用cx_Freeze库生成msi格式安装文件的方法
-
Python使用pip安装报错:is not a supported wheel on this platform的解决方法
-
python中通过pip安装库文件时出现“EnvironmentError: [WinError 5] 拒绝访问”的问题及解决方案
-
Python 安装库文件 is not a supported wheel on this platform的解决方案
-
详解python使用pip安装第三方库(工具包)速度慢、超时、失败的解决方案
-
python: 自动安装缺失库文件的方法
-
Python使用cx_Freeze库生成msi格式安装文件的方法
-
安装MySQL_python驱动报is not a supported wheel错解决方案
-
pip 安装whl文件报 is not a supported wheel on this platform解决方案
-
python中通过pip安装库文件时出现“EnvironmentError: [WinError 5] 拒绝访问”的问题及解决方案