pip安装失败,并显示“连接错误:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:598)”

本文翻译自:pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)”

I am very new to Python and trying to > pip install linkchecker on Windows 7. Some notes: 我是Python的新手,并尝试> pip install linkchecker在Windows 7上> pip install linkchecker 。一些注意事项:

  • pip install is failing no matter the package. 无论软件包如何,pip安装都会失败。 For example, > pip install scrapy also results in the SSL error. 例如, > pip install scrapy也会导致SSL错误。
  • Vanilla install of Python 3.4.1 included pip 1.5.6. 原始安装的Python 3.4.1包含pip 1.5.6。 The first thing I tried to do was install linkchecker. 我尝试做的第一件事是安装linkchecker。 Python 2.7 was already installed, it came with ArcGIS. Python 2.7已经安装,它是ArcGIS附带的。 python and pip were not available from the command line until I installed 3.4.1. 在我安装3.4.1之前,无法从命令行使用pythonpip
  • > pip search linkchecker works. > pip search linkchecker起作用。 Perhaps that is because pip search does not verify the site's SSL certificate. 可能是因为点子搜索无法验证站点的SSL证书。
  • I am in a company network but we do not go through a proxy to reach the Internet. 我在公司网络中,但是我们没有通过代理访问Internet。
  • Each company computer (including mine) has a Trusted Root Certificate Authority that is used for various reasons including enabling monitoring TLS traffic to https://google.com . 每台公司计算机(包括我的计算机)都具有受信任的根证书颁发机构,出于各种原因使用该证书颁发机构,包括启用监视到https://google.com的 TLS流量。 Not sure if that has anything to do with it. 不确定是否与此有关。
  • </
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
`ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)` 这个问题通常是由于 Pythonssl 模块在进行 HTTPS 请求时无法验证服务器证书导致的。以下是一些解决方法: 1. 使用 verify=False 参数禁用证书验证: ``` import requests response = requests.get('https://example.com', verify=False) ``` 这种方法虽然可以解决问题,但是会降低请求的安全性。 2. 更新本地 SSL 证书: 在 Windows 系统上,可以执行以下命令更新证书: ``` pip install --upgrade certifi ``` 在 macOS 上,可以执行以下命令更新证书: ``` sudo /Applications/Python\ {version}/Install\ Certificates.command ``` 在 Linux 上,可以执行以下命令更新证书: ``` sudo apt-get install ca-certificates ``` 3. 指定证书路径: 可以通过设置环境变量 `REQUESTS_CA_BUNDLE` 或者 `CURL_CA_BUNDLE` 来指定证书路径,这样 ssl 模块就可以找到证书进行验证了。 ``` import os import requests os.environ['REQUESTS_CA_BUNDLE'] = '/path/to/cert.pem' response = requests.get('https://example.com') ``` 4. 添加服务器证书到本地信任列表: 可以通过以下步骤将服务器证书添加到本地信任列表: - 通过浏览器访问 HTTPS 网站,获取证书文件。 - 将证书文件保存到本地。 - 在 Python 程序中使用以下代码: ``` import ssl context = ssl.create_default_context() context.load_verify_locations('/path/to/cert.pem') response = requests.get('https://example.com', verify='/path/to/cert.pem') ``` 以上是一些可能的解决方法,具体方法需要根据实际情况选择。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值