8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Homebrewからpyenvインストール、pyenvからPythonをインストールする

Posted at

Pythonをインストールする前にバージョンコントロコールできるpyenvを導入します。

$ brew install pyenv

関連するパッケージ、autoconfとpkg-configもインストールされます。

$ 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
$ 

~/.pyenvディレクトリ作成
~/.bash_profile変更

.bash_profile
export PYENV_ROOT=/usr/local/opt/pyenv
eval "$(pyenv init -)"

インストール可能なものを確認

$ 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

・・・省略・・・

今回は、2系の最新版2.7.9をインストール

$ pyenv install 2.7.9

関連するものもインストールされます。

$ 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

$

インストール確認

$ pyenv versions
* system (set by /usr/local/opt/pyenv/version)
  2.7.9
$ python --version
Python 2.7.6
$
8
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?