Categories
Uncategorized

Switching MacPorts Python installations – Python

This will allow you to switch between different MacPorts python installs.

I have 2.7 and 3.3 on the same computer.

The first thing you can do is get a list of all the MacPorts python installations on the terminal

port select --list python

On my computer this returns

Available versions for python:
	none
	python27 (active)
	python33

…which means that 2.7 is active, so running python in the terminal will return…

Python 2.7.3 (default, Nov 17 2012, 19:54:34) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

which confirms I’m using 2.7.

To change it to Python 3.3 you just need to run this in the terminal…

sudo port select --set python python33

which should then return

Selecting 'python33' for 'python' succeeded. 'python33' is now active.

For the change to be completed we will need to restart the terminal.

Once we restart the terminal, if we run python again, we should now get this

Python 3.3.0 (default, Nov 23 2012, 10:26:01) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

4 replies on “Switching MacPorts Python installations – Python”

I did this and got:
Selecting ‘python33’ for ‘python’ succeeded. ‘python33’ is now active.
[~, 11:20 AM>python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> quit()
[~, 11:21 AM>port select –list python
Available versions for python:
none
python25-apple
python26-apple
python27
python33 (active)
[~, 11:21 AM>python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

Any help would be appreciated!

You may need to restart the terminal.

If that still does not do it, check to see what ‘which Python’ comes up with.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s