MBAにpyenvを入れる

  #python
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.8.4
BuildVersion:   12E3067

rbenvのpython版ないかなーと探してみたらpyenvなんてそのまんまなものがあった。
Simple Python Version Management: pyenvを参考に。

Macでhomebrew使っているなら、brewで入れるのがらくちん。

# brewを最新の状態にする
$ brew update
$ brew upgrade

$ brew search pyenv
pyenv		   pyenv-virtualenv
$ brew install pyenv
Warning: Your Xcode (4.6.3) is outdated
Please update to Xcode 5.0.1.
Xcode can be updated from the App Store.
==> Downloading https://github.com/yyuu/pyenv/archive/v0.4.0-20131116.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/20131116: 199 files, 2.2M, built in 5 seconds

.profileとかに以下を追記する。

if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

profileを再読み込み。

$ source ~/.zprofile

使えるか試してみる。

$ pyenv versions
* system (set by /Users/kobtea/.pyenv/version)
$ pyenv global
system
$ python --version
Python 2.7.2

試しに3.3.2を入れてみる。

$ pyenv install 3.3.2
Downloading Python-3.3.2.tgz...
-> http://yyuu.github.io/pythons/0a2ea57f6184baf45b150aee53c0c8da
Installing Python-3.3.2...
Installed Python-3.3.2 to /Users/kobtea/.pyenv/versions/3.3.2

Downloading setuptools-1.3.2.tar.gz...
-> https://pypi.python.org/packages/source/s/setuptools/setuptools-1.3.2.tar.gz
Installing setuptools-1.3.2...
Installed setuptools-1.3.2 to /Users/kobtea/.pyenv/versions/3.3.2

Downloading pip-1.4.1.tar.gz...
-> https://pypi.python.org/packages/source/p/pip/pip-1.4.1.tar.gz
Installing pip-1.4.1...
Installed pip-1.4.1 to /Users/kobtea/.pyenv/versions/3.3.2


$ pyenv rehash
$ pyenv versions
* system (set by /Users/kobtea/.pyenv/version)
  3.3.2
$ pyenv global 3.3.2
$ pyenv version
3.3.2 (set by /Users/kobtea/.pyenv/version)
$ pip --version
pip 1.4.1 from /Users/kobtea/.pyenv/versions/3.3.2/lib/python3.3/site-packages/pip-1.4.1-py3.3.egg (python 3.3)

すごいpipがもう使えるようになってる!!ステキ!!
ついでにipythonを入れてみる。

$ pip install ipython
Downloading/unpacking ipython
  Downloading ipython-1.1.0.tar.gz (8.7MB): 8.7MB downloaded
  Running setup.py egg_info for package ipython
...

$ pip list
ipython (1.1.0)
pip (1.4.1)
setuptools (1.3.2)

らくちん。


comments powered by Disqus