• pip安装第三方包报错:There was a problem confirming the ssl certificate


    错误提示

    突然使用python直接使用pip install xx时,出现报错:

    Could not fetch URL https://pypi.org/simple/pymysql/: There was a problem confirming the ssl certificate: HTTPSConnectio
    nPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pymysql/ (Caused by SSLError(SSLError(1, '[SSL:
    CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)) - skipping

    报错内容如下:

    PS C:Usersyinha> pip install pymysql
    WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /simple/pymysql/
    WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /simple/pymysql/
    WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /simple/pymysql/
    WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /simple/pymysql/
    WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /simple/pymysql/
    Could not fetch URL https://pypi.org/simple/pymysql/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pymysql/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)) - skipping
    ERROR: Could not find a version that satisfies the requirement pymysql (from versions: none)
    ERROR: No matching distribution found for pymysql

    解决过程

    一开始以为是ide环境出了问题,后来在终端,在虚拟环境测试都会报错。

    1. 重装python  无效

    2.重装pip    无效

    python -m pip uninstall pip
    
    C:Python36Scripts>easy_install.exe -i http://mirrors.aliyun.com/pypi/simple/ pip

    3.添加--trusted-host  有效

    但是每次安装增加此参数,比较麻烦

    pip install pymysql -i http://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn

    4.创建pip配置pip.ini。  有效

    (1)在系统目录C:Users用户AppDataRoaming新建pip文件夹;

    (2)在pip文件夹下新建pip.ini文件,并写入如下配置:

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

     5.关闭Fiddler

    看到这里真的是崩溃,开启它之后运行python会自动改变端口,造成ssl错误。

    不多解释了,关掉就好,说多了都是泪。

    顺便说一下:开启Fiddler后,对requests模块也会产生ssl认证的报错。

    之前没发现这个原因时,就靠如下方法对付:

    # 忽略警告
    requests.packages.urllib3.disable_warnings()
    #取消认证
    requests.get(url=url,cookies=cookies,verify=False)

      

  • 相关阅读:
    网页布局1
    下拉菜单的制作
    状态玻璃效果菜单(实例)
    鼠标经过时整行变色
    鼠标经过时单元格变色
    Bootstrap3.0入门学习系列规划[持续更新]
    使用jQuery实现简单的拖动效果
    解决VS2012新建MVC3等项目时,收到加载程序集“NuGet.VisualStudio.Interop…”的错误
    Flash3D引擎:Away3D 4.1 Alpha版介绍
    Away3d 基础 1 ---对一个简单类的解释
  • 原文地址:https://www.cnblogs.com/yinhaiping/p/13375375.html
Copyright © 2020-2023  润新知