pip3(9.0.1)安装或升级软件时提示“SSL: CERTIFICATE_VERIFY_FAILED”的解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Amio_/article/details/80224458

博文章节


pip版本及报错信息

pip版本

(py3env) C:\Virtualenv\py3env>pip -V
pip 9.0.1 from c:\virtualenv\py3env\lib\site-packages (python 3.6)

报错信息
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed)

(py3env) C:\Virtualenv\py3env>C:/Virtualenv/py3env/Scripts/python.exe -m pip install -U pylint
Collecting pylint
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:732: The handshake operation timed out',))': /simple/pylint/
  Could not fetch URL https://pypi.python.org/simple/pylint/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) - skipping
  Could not find a version that satisfies the requirement pylint (from versions: )
No matching distribution found for pylint

问题原因及解决方法

问题原因
Could not fetch URL https://pypi.python.org/simple/pylint/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)
翻译过来:不能从url(https://pypi.python.org/simple/pylint/)获取pylint包,原因为校验SSL证书时出现错误,证书校验失败。

解决方法一:
更新pip,我们现在的pip版本为9.0.1,而现在最新的pip版本为10.0.1,可以使用python -m pip install --upgrade pip命令来更新,如果仍提示以上错误,请尝试“解决方法二

解决方法二:
官网下载最新的pip安装包,如下载pip-10.0.1-py2.py3-none-any.whl文件或pip-10.0.1.tar.gz文件,存放于本地的某一目录(最好不要有中文路径),使用python -m pip install pip-10.0.1-py2.py3-none-any.whl更新,如下:

(py3env) C:\Virtualenv\py3env>python -m pip install pip-10.0.1-py2.py3-none-any.
whl
Processing c:\virtualenv\py3env\pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-10.0.1
(py3env) C:\Virtualenv\py3env>pip -V
pip 10.0.1 from c:\virtualenv\py3env\lib\site-packages\pip (python 3.6)

再次尝试安装软件(成功安装)

(py3env) C:\Virtualenv\py3env>C:/Virtualenv/py3env/Scripts/python.exe -m pip install -U pylint
Collecting pylint
  Using cached https://files.pythonhosted.org/packages/8b/62/b2c07085dd7bb4b7e8bb813873421692c1157191e87234550a1c39dff232/pylint-1.8.4-py2.py3-none-any.whl
Requirement not upgraded as not directly required: six in c:\virtualenv\py3env\lib\site-packages (from pylint) (1.11.0)
Requirement not upgraded as not directly required: colorama; sys_platform == "win32" in c:\virtualenv\py3env\lib\site-packages (from pylint) (0.3.9)
Collecting isort>=4.2.5 (from pylint)
  Using cached https://files.pythonhosted.org/packages/1f/2c/22eee714d7199ae0464beda6ad5fedec8fee6a2f7ffd1e8f1840928fe318/isort-4.3.4-py3-none-any.whl
Collecting astroid<2.0,>=1.6 (from pylint)
  Using cached https://files.pythonhosted.org/packages/f8/59/12a1d965bb99b595bfd72cc9a44863a0c00a2c05c38178f6139285bb00b5/astroid-1.6.3-py2.py3-none-any.whl
Collecting mccabe (from pylint)
  Using cached https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl
Collecting wrapt (from astroid<2.0,>=1.6->pylint)
  Using cached https://files.pythonhosted.org/packages/a0/47/66897906448185fcb77fc3c2b1bc20ed0ecca81a0f2f88eda3fc5a34fc3d/wrapt-1.10.11.tar.gz
Collecting lazy-object-proxy (from astroid<2.0,>=1.6->pylint)
  Using cached https://files.pythonhosted.org/packages/7c/71/e7a10cab32c9fc37467e2f211a46328784a07bc5d7a977b1fe6b01a5f1a1/lazy_object_proxy-1.3.1-cp36-cp36m-win_amd64.whl
Building wheels for collected packages: wrapt
  Running setup.py bdist_wheel for wrapt ... done
  Stored in directory: C:\Users\zhenfeng.liu\AppData\Local\pip\Cache\wheels\48\5d\04\22361a593e70d23b1f7746d932802efe1f0e523376a74f321e
Successfully built wrapt
Installing collected packages: isort, wrapt, lazy-object-proxy, astroid, mccabe, pylint
Successfully installed astroid-1.6.3 isort-4.3.4 lazy-object-proxy-1.3.1 mccabe-0.6.1 pylint-1.8.4 wrapt-1.10.11

题外话(将pip源改为国内镜像)

1、到pip的安装路径,如C:\Virtualenv\py3env\Scripts创建pip.ini文件,内容如下:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com

pip(10.0.1)包快捷下载

猜你喜欢

转载自blog.csdn.net/Amio_/article/details/80224458
今日推荐