zoukankan      html  css  js  c++  java
  • 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)

      

  • 相关阅读:
    笔试算法题(45):简介
    笔试算法题(44):简介
    笔试算法题(43):布隆过滤器(Bloom Filter)
    笔试算法题(42):线段树(区间树,Interval Tree)
    笔试算法题(41):线索二叉树(Threaded Binary Tree)
    笔试算法题(40):后缀数组 & 后缀树(Suffix Array & Suffix Tree)
    笔试算法题(39):Trie树(Trie Tree or Prefix Tree)
    笔试算法题(38):并查集(Union-Find Sets)
    笔试算法题(37):二叉树的层序遍历 & 最长递增的数字串
    mysql cmd 启动服务
  • 原文地址:https://www.cnblogs.com/yinhaiping/p/13375375.html
Copyright © 2011-2022 走看看