在查看pip支持的文件名和版本时,常会提示module ‘pip’ has no attribute ‘pep425tags’,这主要是使用的pip版本的问题。
win32常用:
import pip;
print(pip.pep425tags.get_supported())
amd64常用:
但是这些在我的电脑上都不管用,有用的命令为在CMD执行:
python -m pip debug --verbose
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支持的文件名和版本了。