Kalo
Kalo

Reputation: 13

I can't change the default Python version from Apple supplied 2.7.2 to 3.2.2 (OS10.7)

in Lion, have installed python 3.2.2 from python.org. It comes with a terminal command that is supposed to move this version of python earlier by updating my shell profile. When i run it, and then check my default python in Terminal, it still says 2.7.2 which is the Apple supplied one.

Do I need to run the command with sudo to get it to change the default python to 3.2.2?

I've also tried the VERSIONER method but it doesn't work.

Upvotes: 1

Views: 1999

Answers (2)

ashwoods
ashwoods

Reputation: 2289

Unfamiliar with osX, but as several system applications might depend on a certain python version, it might be a bad idea to swap the default.

One alternative that might suite your needs is to use pythonbrew, it allows you to have several python versions side by side and lets you set a default version on a user to user basis, without having to meddle with your system python, among other things. It is the equivalent of RVM for those who are familiar with ruby, or a sort of virtualenv for python interpreters. One big advantage is that it allows you to easily install and use the exact python versions you need independently from what is available in your operating system.

Some examples:

Install a python interpreter:

pythonbrew install 2.7.2

Permanently use the specified python (for current user):

pythonbrew switch 2.7.2 
pythonbrew switch 3.2 

Use the specified python in current shell:

pythonbrew use 2.7.2 

Runs a named python file against specified and/or all pythons:

pythonbrew py test.py
pythonbrew py -v test.py # Show verbose output
pythonbrew py -p 2.7.2 -p 3.2 test.py # Use the specified pythons

The only downside of pythonbrew, is the need of a compiler and header files, and that an install can take a bit of time, as it compiles from source.

Upvotes: 0

Ned Deily
Ned Deily

Reputation: 85055

For Python 3 interpreters, you must enter python3 not python.

$ python -V
Python 2.7.2
$ python3 -V
Python 3.2.2

For more background on the current recommendation that python refer to a version of Python 2 and python3 refer to a version of Python 3, see the draft PEP 394 - The "python" Command on Unix-Like Systems.

Upvotes: 3

Related Questions