错误信息如下:
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)'),))
各种办法试了一遍,查资料,网上给的方法主要有以下几个:
1.关掉ssl验证,request时设置verify=false
2.指定ssl证书,requests.get("https://www.baidu.com",cert="xxx/xxx/xxx/xxx")
试了一遍发现都没有用,继续翻资料
requests的用法文档:https://2.python-requests.org//zh_CN/latest/user/advanced.html#ssl
发现有这么一段话:
忽然反应过来,问了下同事,发现代码在同事电脑上可以正常运行,在自己电脑上却报错。应该是环境问题。
更新下certifi包,相关的也更新或者安装下,包括pyOpenSSL,cryptography,其中cryptography依赖的包比较多,耐心一个一个下吧,更新完后,问题解决了!