背景:
當(dāng)使用pip安裝第三方包時(shí),經(jīng)常會(huì)遇到類似以下ssl錯(cuò)誤,如安裝pytest包,使用命令:
pip install pytest
Collecting pytest
Could not fetch URL https://pypi.python.org/simple/pytest/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777) - skipping
Could not find a version that satisfies the requirement pytest (from versions: )
No matching distribution found for pytest
臨時(shí)解決辦法:
使用如下命令:
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pytest
永久解決辦法:(更改pip安裝源為國(guó)內(nèi)鏡像)
1.在如下目錄創(chuàng)建pip文件夾: C:\Users\XXX\AppData\Roaming;
2.在pip文件夾內(nèi)創(chuàng)建一個(gè)文件:pip.ini;
3.在pip.ini文件內(nèi)寫(xiě)入如:(本例為阿里鏡像)乍惊;
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
4.保存后蔗候,用pip安裝時(shí)就不會(huì)再報(bào)SSL證書(shū)錯(cuò)誤完慧;