jekylog

All doggs wanna be a Geek

Pythonのバージョン切り替えでハマった

まずは現在のバージョンを確認する

$ python -V
Python 2.5.6

たしか2.7がインストールされていたのでpython_selectで切り替える

$ sudo python_select python27
sudo: python_select: command not found

あれ?ググっても記事は古いけど上記のようにして切り替えてるのに。とりあえず「python_select command not found」でググると簡単に解決方法が見つかった。

どうやらport selectで切り替えるらしい。ってかそういう風に切り替えてたけどサッパリ忘れてる。

使用可能なPythonのバージョンを確認する

上記の参考サイトのまんま打ってみる。

$ port select --list python
Available versions for python:
    none
    python25 (active)
    python25-apple
    python26-apple
    python27-apple

「port select」で切り替える

$ sudo port select --set python python27-apple
Selecting 'python27-apple' for 'python' succeeded. 'python27-apple' is now active.

ターミナルの再起動後にバージョンを改めて確認すると、

$ python -V
Python 2.7.1

切り替えれたー!

さすがエロサイト作った人の解説だけに分かりやすいし痒いところまでケアする記事、助かりました。

Fork me on GitHub