2011年3月17日木曜日

Tips: Multiple Python Versions with MacPorts

I wanted to try python3 with MacPorts on my macbook, but wasn't sure if I want to remove older versions yet (for GAE and such).

Anyways I searched and installed the latest one available with MacPorts.
$ port search python3
which lists python versions 3.1.2 and 3.2.  I wanted the newer one, so I did:
$ sudo port install python32
to install python 3.2 successfully.

Then I checked the version:
$ python -V
Python 2.5.4

So python still pointed to an old version.  I could type "python3.2" and run the 3.2 version (actually I've managed to use other versions like that).

Then I found a discussion on this topic:
http://superuser.com/questions/35256/how-can-i-change-the-default-python-version-on-snow-leopard
 

OK, so the python_select package seems just what I wanted.
$ sudo port install python_select
$ python_select -l
gave me some output:
Available versions:
current none python26 python26-apple python27 python32
Now I tried:
$ python_select python32

which didn't work, because it modifies the macports system info...

A command that works:
$ sudo python_select python32
$ python -V
Python 3.2

0 件のコメント: