最近在做CTF密码学类题目时,需要安装一些Python库,但是直接使用 pip install xxx
指令联网安装库时经常会出现满屏幕红色报错的情况,转而采用下载whl文件再使用 pip install xxx.whl
进行安装的方法,结果还是会出现pip
安装报错:is not a supported wheel on this platform
的情况:
下面提供解决方案:打开 PowerShell 或者 命令提示符窗口(CMD),输入下列命令:
>>> python -m pip debug --verbose
此处需要注意的是,在多个python版本共存的计算机上,输入处“python”需要根据希望安装的目标Python版本来决定。例如,在你的计算机中输入“python”进入的是Python3环境,输入“python2”进入的是Python2环境,那么上述的命令就是将希望安装的包通过pip安装至Python3环境下;若希望将包通过pip安装至Python2环境下,只需要将“python”替换为“python2”即可。
运行命令后,可得到下列结果(此处展示的是我的计算机中运行的结果供大家参考):
➜ 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.3 from C:\Users\SongW\AppData\Local\Programs\Python\Python37\lib\site-packages\pip (python 3.7)
sys.version: 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
sys.executable: C:\Users\SongW\AppData\Local\Programs\Python\Python37\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(): C:\Users\SongW\AppData\Local\Programs\Python\Python37\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: 27
cp37-cp37m-win_amd64
cp37-abi3-win_amd64
cp37-none-win_amd64
cp36-abi3-win_amd64
cp35-abi3-win_amd64
cp34-abi3-win_amd64
cp33-abi3-win_amd64
cp32-abi3-win_amd64
py37-none-win_amd64
py3-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
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之后的输出内容。在Compatible tags:以下得到的列表中,每一个元素都代表着一种你的机器可以安装的whl文件的版本。
比如 cp37-cp37m-win_amd64
对应的可以安装的whl文件版本是:
XXXX‑X.X.X‑cp37‑cp37m‑win_amd64.whl
按照这种方法就可以准确的找出你的机器可以安装的whl文件的版本了~