现象

        在python环境中安装插件包时,出现错误如:

Could not fetch URL https://pypi.org/simple/requests/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/requests/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))) - skipping Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))) - skipping

原因

        系统根证书缺失或过期

解决方案

  • 升级证书
# mac
/Applications/Python*/Install\ Certificates.command

# win
pip install --upgrade certifi

  • 使用新证书
# mac python3
export SSL_CERT_FILE=$(python3 -m certifi)

# mac python
export SSL_CERT_FILE=$(python -m certifi)


# win python3
export SSL_CERT_FILE=$(python3 -m certifi)

# win python
export SSL_CERT_FILE=$(python -m certifi)

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐