Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am beginning to learn Python, and want to "upgrade" my Python installation os OS X 10.6.5.

I know it's a bad idea to directly upgrade the Python install, so I have installed Python 3.1 separately from the default Python install (2.6.1).

However, whenever I use the "python" command from the terminal, it starts up Python 2.6.1.

I have tried multiple recommended ways to get the "python" command to start up the newest version, rather then the default:

1) I have tried running the script "Update Shell Profile.command" script in the Applications/Python 3.1 directory, and get the following output:

    This script will update your shell profile when the 'bin' directory
of python is not early enough of the PATH of your shell.
These changes will be effective only in shell windows that you open
after running this script.
All right, you're a python lover already

2) I have created a file named .profile in my home directory, with the following contents:

#### Let's take care of our $PATH
# A backup of the original $PATH
# /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

# My preferred order - /usr/local goes first, damn it!
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin

As recommended here: http://superuser.com/questions/29652/how-do-i-properly-update-python-on-mac-os-x

Neither one changes the effects of the "python" command; it still starts up Python 2.6.1. I can still start Python 3.1 by using the command python3.1, but I'd like to set Python 3.1 to the default for the "python" command.

share|improve this question
    
In the terminal what does echo $PATH show? –  Mark Dec 19 '10 at 9:39

3 Answers 3

At least with MacPorts, this is done with the python_select command. It may not be immediately applicable to your setup (you didn't mention MacPorts) but it's somewhere to start.

share|improve this answer

What shell do you use? On OS X, /bin/bash is the default, so try editing .bashrc or .bash_profile instead.

share|improve this answer
    
Thanks for the answer. What exactly would I add to .bash_profile? I added the new PATH line from the .profile I showed above, but to no effect. –  vorbb Dec 19 '10 at 4:26
1  
You have to use export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin. export puts it into the environment. –  Andrew Dec 20 '10 at 17:03

All you have to do to change this is open Terminal.app, and enter the following:

defaults write com.apple.versioner.python Version 3.1

This will change the default used in the terminal. You can also install separate IDLEs if you want to run from a GUI.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.