https://github.com/yyuu/pyenv
$ brew update
$ brew install pyenv
更新pyenv, 用
brew upgrade pyenv
.
上述安装完成则根据以下提示进行配置
==> Caveats
To use Homebrew's directories rather than ~/.pyenv add to your profile:
export PYENV_ROOT=/usr/local/var/pyenv
To enable shims and autocompletion add to your profile:
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
==> Summary
🍺 /usr/local/Cellar/pyenv/1.0.7: 548 files, 2.2M, built in 51 seconds
按照提示,将以上的两条语句添加到profile里就可以了,由于我用的shell是zsh,所以我在.zshrc里追加
export PYENV_ROOT=/usr/local/var/pyenv
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
$ exec $SHELL
$ pyenv install x.x.x