今天在虛擬環境中使用pip 安裝pylint的時候發現出現了TLS版本太低問題。html
(py3env) ☁ py3env pip install pylint
Collecting pylint
Could not fetch URL https://pypi.python.org/simple/pylint/:
There was a problem confirming the ssl certificate:
[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:720) - skipping
Could not find a version that satisfies the requirement pylint (from versions: )
No matching distribution found for pylintpython
而後想起了去年有一篇文章說python.org和pypi將中止對TLS 1.0和1.1的支持,而後又找到了這篇文章git
http://pyfound.blogspot.in/2017/01/time-to-upgrade-your-python-tls-v12.html github
文章中明確說明bash
Mac users should pay special attention. So far, the system Python shipped with MacOS does not yet support TLSv1.2 in any MacOS version; beginning next June these system Pythons will no longer be able to "pip install" packages.異步
Mac用戶應該特別注意,到目前爲止,MacOS附帶的系統Python在任何MacOS版本中都不支持TLSv1.2。因此是時候升級一下python3的版本了,並且能夠體驗一下python 3.6的異步解析式和生成器。fetch
記錄一下升級到os X升級到python3.6的過程。ui
一、有必要先切換一下Homebrew的源,中科大鏡像源url
替換brew.git: cd "$(brew --repo)" git remote set-url origin https://mirrors.ustc.edu.cn/brew.git 替換homebrew-core.git: cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
二、更新python3,直接安裝就會自動更新。code
brew install python3
更新過程當中會遇到一個問題:
Error: The `brew link` step did not complete successfully
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
遇到這個權限問題的時候執行下面,
sudo mkdir -p /usr/local/Frameworks sudo chown -R $(whoami) /usr/local/*
而後在執行
brew link python3
可能會遇到以後這個問題:
Linking /usr/local/Cellar/python3/3.6.4_1...
Error: Could not symlink bin/idle3
Target /usr/local/bin/idle3
already exists. You may want to remove it:
rm '/usr/local/bin/idle3'
To force the link and overwrite all conflicting files:
brew link --overwrite python3
To list all files that would be deleted:
brew link --overwrite --dry-run python3
就更具提示把該刪除的刪除一下就行了
rm /usr/local/bin/idle3 rm /usr/local/bin/pydoc3 在執行 brew link --overwrite python3
這樣就安裝成功了。
參考連接:
brew源更新: https://www.zhihu.com/question/31360766
低版本TLS中止支持公告 : http://pyfound.blogspot.in/2017/01/time-to-upgrade-your-python-tls-v12.html
brew安裝python3 issue : https://github.com/Homebrew/homebrew-core/issues/20985