Introduce pyenv, which allows version control calls before installing Python.
$ brew install pyenv
The related packages, autoconf and pkg-config, are also installed.
$ brew install pyenv
==> Installing dependencies for pyenv: autoconf, pkg-config
==> Installing pyenv dependency: autoconf
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/autoconf-2.
Already downloaded: /Library/Caches/Homebrew/autoconf-2.69.yosemite.bottle.1.tar.gz
==> Pouring autoconf-2.69.yosemite.bottle.1.tar.gz
? /usr/local/Cellar/autoconf/2.69: 70 files, 3.1M
==> Installing pyenv dependency: pkg-config
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-
Already downloaded: /Library/Caches/Homebrew/pkg-config-0.28.yosemite.bottle.2.tar.gz
==> Pouring pkg-config-0.28.yosemite.bottle.2.tar.gz
? /usr/local/Cellar/pkg-config/0.28: 10 files, 612K
==> Installing pyenv
==> Downloading https://github.com/yyuu/pyenv/archive/v20141211.tar.gz
######################################################################## 100.0%
==> Caveats
To enable shims and autocompletion add to your profile:
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
To use Homebrew's directories rather than ~/.pyenv add to your profile:
export PYENV_ROOT=/usr/local/opt/pyenv
==> Summary
? /usr/local/Cellar/pyenv/20141211: 315 files, 2.7M, built in 4 seconds
$
Create ~ / .pyenv directory ~ / .bash_profile change
.bash_profile
export PYENV_ROOT=/usr/local/opt/pyenv
eval "$(pyenv init -)"
Check what can be installed
$ pyenv install -l
Available versions:
2.1.3
2.2.3
2.3.7
2.4
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
2.5
2.5.1
2.5.2
2.5.3
2.5.4
2.5.5
2.5.6
2.6.6
2.6.7
2.6.8
2.6.9
2.7-dev
2.7
2.7.1
2.7.2
2.7.3
2.7.4
2.7.5
2.7.6
2.7.7
2.7.8
2.7.9
···abridgement···
This time, install the latest version 2.7.9 of 2 series
$ pyenv install 2.7.9
Related ones will also be installed.
$ pyenv install 2.7.9
Downloading readline-6.3.tar.gz...
-> http://ftpmirror.gnu.org/readline/readline-6.3.tar.gz
Installing readline-6.3...
Installed readline-6.3 to /usr/local/opt/pyenv/versions/2.7.9
Downloading Python-2.7.9.tgz...
-> https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
Installing Python-2.7.9...
Installing setuptools from https://bootstrap.pypa.io/ez_setup.py...
Installing pip from https://bootstrap.pypa.io/get-pip.py...
Installed Python-2.7.9 to /usr/local/opt/pyenv/versions/2.7.9
$
Installation confirmation
$ pyenv versions
* system (set by /usr/local/opt/pyenv/version)
2.7.9
$ python --version
Python 2.7.6
$
Recommended Posts