brew install pyenv

[^1] brew下载pyenv时,可能遇到403,无法解析,原因是DNS解析被污染,在/etc/hosts文件中添加

199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
  1. brew install pyenv
  2. vim ~/.bash_profile
export PYENV_ROOT=/usr/local/var/pyenv
export PATH="$PYENV_ROOT/shims:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)";fi
  1. pyenv versions
  2. pyenv global <xxx_version>