使用pip安裝包提示TLS證書錯誤解決辦法

 

使用pip安裝python包的時候,常常會出現如下相似的錯誤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能夠解決這個問題。linux

    可是若是使用傳統的python -m pip install --upgrade pip的方式,仍是會出現那個問題。macos

    這是一個相互矛盾的問題,你由於TLS證書的問題須要去升級pip,升pip的時候又由於TLS證書的緣由不能下載最新版本的pip。bootstrap

    所以只能手動的去升級pip。bash

 

mac或者linux操做系統:在終端下執行命令:curl

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

 

而後再使用pip安裝軟件包fetch

(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

  

overui

 

參考:https://blog.csdn.net/nunchakushuang/article/details/80049528url

相關文章
相關標籤/搜索