Time To Upgrade Your Python

今天在虚拟环境中使用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

相关文章
相关标签/搜索