Daily Archives: 2015/12/29

在Mac里安装单独的python

mac已经自带了python了,版本也还比较新。如果想自己控制python的版本的话,可以用brew来安装单独的python.

brew install python

brew安装的命令会在/usr/local/bin里面,如果系统自带了一些工具在/usr/bin里,那么brew安装的可能无法被使用到。所以需要将/usr/local/bin放到 /usr/bin前面去

brew doctor会提供修复的命令:

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc

修改之后source ~/.zshrc就可以使用最新版的python了

➜  python --version
Python 2.7.11
➜  which python
/usr/local/bin/python