1. 程式人生 > 實用技巧 >Python2.7 pip install Certificate did not match expected hostname

Python2.7 pip install Certificate did not match expected hostname

異常資訊

WARNING: Certificate did not match expected hostname: mirrors.aliyun.com. Certificate: {'notAfter': 'Oct 18 12:00:00 2020 GMT', 'subjectAltName': (('DNS', 'img.ucdl.pp.uc.cn'), ('DNS', 'iscsi.ucdl.pp.uc.cn'), ('DNS', 'slient.ucdl.pp.uc.cn'), ('DNS', 'alissl.ucdl.pp.uc.cn'), ('DNS', 'cdn.osupdateservice.yunos.com
'), ('DNS', 'oss.ucdl.pp.uc.cn')), 'subject': ((('commonName', u'img.ucdl.pp.uc.cn'),),)} Could not fetch URL https://mirrors.aliyun.com/pypi/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='mirrors.aliyun.com', port=443): Max retries exceeded with url: /pypi/simple/pip/ (Caused by SSLError(CertificateError("
hostname 'mirrors.aliyun.com' doesn't match either of 'img.ucdl.pp.uc.cn', 'iscsi.ucdl.pp.uc.cn', 'slient.ucdl.pp.uc.cn', 'alissl.ucdl.pp.uc.cn', 'cdn.osupdateservice.yunos.com', 'oss.ucdl.pp.uc.cn'",),)) - skipping

錯誤原因

證書校驗引發異常, 此時可以信任此網站不在進行證書認證

pip install xxx -i https://mirrors.aliyun.com/pypi/simple --trusted-host=mirrors.aliyun.com