首页
学习
活动
专区
工具
TVP
发布

使用pip安装包提示TLS证书错误解决办法

使用pip安装python包的时候,经常会出现以下类似的错误

(test) dongchang-5:test baoshan$ pip3 install requests

Collecting requests

Could not fetch URL https://pypi.python.org/simple/requests/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645) - skipping

Could not find a version that satisfies the requirement requests (from versions: )

No matching distribution found for requests

出现这个错误的原因是python.org已经不支持TLSv1.0和TLSv1.1了。更新pip可以解决这个问题。但是如果使用传统的python -m pip install --upgrade pip的方式,还是会出现那个问题。

这是一个互相矛盾的问题,你因为TLS证书的问题需要去升级pip,升pip的时候又因为TLS证书的原因不能下载最新版本的pip。这时候就没有办法了,只能手动的去升级pip。

mac或者linux操作系统:在终端下执行命令:

curl https://bootstrap.pypa.io/get-pip.py | python

然后再使用pip安装软件包

(test) dongchang-5:test baoshan$ pip3 install numpy

Collecting numpy

Downloading https://files.pythonhosted.org/packages/10/59/da8c94da6eaa44651c254dbaec2c901544ab1f88f410c47e2d3092e2d88f/numpy-1.15.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (24.4MB)

100% 25.3MB 298kB/s

Installing collected packages: numpy

Successfully installed numpy-1.15.0

谢谢!

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180803G1WAPX00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券