Skip to content

Instantly share code, notes, and snippets.

@huguangju
Last active January 22, 2017 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huguangju/73b74619adf782f2a59bb60c6befb4a5 to your computer and use it in GitHub Desktop.
Save huguangju/73b74619adf782f2a59bb60c6befb4a5 to your computer and use it in GitHub Desktop.
为Mac设置Python多版本开发环境

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

重启shell以使路径变更生效

$ exec $SHELL

安装对应版本的python

$ pyenv install x.x.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment