LoginSignup
1
1

More than 5 years have passed since last update.

macportsのコマンドに対するシンボリックリンクを貼る

Posted at

前書き

自分のmacは追加のソフトウェアをmacportsでインストールしているのですが、ターミナルでpythonと実行しても最初からmacにインストールされている2.7.1側が呼ばれるため、djangoのテスト実行等のためにはpython2.7で実行しなければならず不便していました。
最近になって、ようやくmacports内のコマンドにシンボリックリンクを貼ることが出来るのを知ったので、メモ代わりに残しておきます。

本題

macports のselectコマンドで操作していきます。

まずは現状を調べる

$ port select --list python
Available versions for python:
    none (active)
    python24
    python25-apple
    python26
    python26-apple
    python27
    python27-apple
$ python
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D

--listで調べてみると、なるほど、noneがactiveになっている。
よって、pythonでは上記の通り2.7.1のものが呼ばれている。。。

切り替える

$ sudo port select --set python python27
Password:
Selecting 'python27' for 'python' succeeded. 'python27' is now active.
$ port select --list python
Available versions for python:
    none
    python24
    python25-apple
    python26
    python26-apple
    python27 (active)
    python27-apple

--setで切り替え可能。--listで再確認すればpython27がactiveになっている。
なお、新しいターミナルで初めて有効になる

$ python
Python 2.7.3 (default, Nov  7 2012, 10:38:10) 
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
1
1
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
1
1