Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to learn Python using my Mac.

Now I want to setup a Python version >= 3.1.3, because my materials for learning are using this version.

Typing python into terminal results version 2.6.1, using the dmg installer on python.org doesn't have an effect on the python version in terminal, but it's bundled with an own shell under Applications/Python 3.1/Idle.app

Should I use this shell for learing or is there a better way, updating the Python version bundled with Snow Leopard?

I already tried defaults write com.apple.versioner.python Version 3.1.3 or defaults write com.apple.versioner.python Version 3.0 without any result.

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

Python 3 breaks things. That's why it doesn't replace Python 2, and python still launches 2.


To get Python 3, type python3. You might need to change your $PATH by editing ~/.bash_profile and adding:

PATH="/Library/Frameworks/Python.framework/Versions/3.1/bin:${PATH}"
export PATH

You could define a shell function or alias to map python to python3, this way old scripts would continue to run, and you can type python and get version 3.

Add to .bash_profile:

alias python='python3'

/usr/bin/env python continues to provide Python 2.

share|improve this answer
add comment

You don't really want to change th default, as the syntax is different enough that apps that require python 2.x will break under 3.

I think that if you type python3 instead of python then it will uses version 3 ( or maybe I just set mine up like that!)

share|improve this answer
add comment

Using IDLE is just fine for learning Python. You can either save files with your code or run individual lines of code from the shell.

If you want, you can use text editors such as TextMate or an IDE such as Eclipse with your Mac install of Python 3.1. You just need to point those applications to the location of the Python interpreter.

I did the following post on setting up TextMate with Python 3 in this way. Hope it helps.

share|improve this answer
add comment

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.