python_selectで簡単バージョン切り替え

Pythonのバージョンを切り替えてくれるpython_selectを入れてみた。

インストール

sudo port install python_select

切り替え

% python_select
usage: python_select [-n] [-d] [-r] [-h] [-v] version

-n        Show commands to do selection but do not execute them.
-d        Show debug messages during execution
-h        Display this help info.
-v        Display version of python_select.
-l        List available options for version.
-s        Show the currently selected version

% python_select -l
Available versions:
current none python25 python26-apple python31
% python_select -s
python26-apple
% python --version
Python 2.6.1
% sudo python_select python31
Selecting version "python31" for python
% python --version
Python 3.1.1
% sudo python_select current
Selecting version "current" for python
% python --version
Python 3.1.1
% sudo python_select none
Selecting version "none" for python
% python --version
Python 2.6.1
% python_select -s
none

noneはpython_selectによる変更を無効化する?インストール直後はnoneだったのかも。
currentの存在意義はよくわからん。

参考:複数バージョンのPythonを華麗に切り替える - When it’s ready.