1. 程式人生 > >Mac 升級pip 9.0.1到10.0.1遇坑記錄

Mac 升級pip 9.0.1到10.0.1遇坑記錄

首先你要pip安裝某一個工具的時候遇到下面類似的錯誤

Traceback (most recent call last):
  File "/Users/finaris/PycharmProjects/test/test/test.py", line 14, in <module>
    c.request('GET', '/api/config/v1/aaa/users', headers=headers)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1106, in request
    self._send
_request(method, url, body, headers) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1151, in _send_request self.endheaders(body) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1102, in endheaders self._send_output(message_body) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py"
, line 934, in _send_output self.send(msg) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 877, in send self.connect() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1260, in connect server_hostname=server_hostname) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py"
, line 377, in wrap_socket _context=self) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 752, in __init__ self.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 988, in do_handshake self._sslobj.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 633, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645)

也許大多數人直接執行下面的程式碼就可以解決問題了

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

但是我又遇到了其他問題,類似下面的

ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
//先到下載的目錄
cd /Users/ccMac/Downloads 

//執行
python get-pip.py

假如提示你:

Collecting pip
  Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
    29% |█████████▌                      | 389kB 4.1kB/s eta 0:03:46
    Exception:
    .....

那麼就把這個檔案下載下來,自己安裝

https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl

下載下來後,然後安裝

pip install /Users/ccMac/Downloads/pip-10.0.1-py2.py3-none-any.whl 

假如提示你下面的錯誤:

....
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'

這樣執行:

sudo pip install /Users/liumengkai/Downloads/pip-10.0.1-py2.py3-none-any.whl 

finally:

Successfully installed pip-10.0.1

pip -V
pip 10.0.1 from /Library/Python/2.7/site-packages/pip (python 2.7)