views:

1287

answers:

7

I'd like to upgrade the default python installation (2.5.1) supplied with OS X Leopard to the latest version. Please let me know how I can achieve this.

Thanks

+3  A: 

May I suggest you leave the "Default" be, and install Python in /usr/local/bin.

  1. Download python
  2. Unzip it
  3. ./configure
  4. make
  5. sudo make install

done.

Since /usr/local/bin comes before /usr/bin in the $PATH, you will invoke 2.6 when you type python, but the OS will remain stable...

gahooa
I had to learn my lesson the hard way on this one. Do as gahooa says. Having multiple installs is not uncommon, so don't worry about having the original version still around. So: don't upgrade, install new version!
vgm64
A: 

I believe there are a few options. The one I like is to install alternative UNIX software on my Macs using MacPorts, http://www.macports.org/ -- this way the new software is installed in a different directory and won't mess up anything depending on the apple-installed version, and macports also has a nice way of keeping their installed software up to date. I believe MacPorts helps take care of dependencies as well.

Devin Ceartas
+2  A: 

You have a number of options

  • Install with MacPorts or Fink, e.g.:

    sudo port install python2.6
    
  • Install from the disc image from python.org
  • Install from source:

    tar xzvf Python-2.6.3.tgz
    cd Python-2.6.3
    ./configure && make && sudo make install
    
Adam Rosenfield
Is there any option to update using the Apple's Python distribution?
jpartogi
+9  A: 

When an OS is distributed with some specific Python release and uses it for some OS functionality (as is the case with Mac OS X, as well as many Linux distros &c), you should not tamper in any way with the system-supplied Python (as in, "upgrading" it and the like): while Python strives for backwards compatibility within any major release (such as 2.* or 3.*, this can never be 100% guaranted; your OS supplied tested all functionality thoroughly with the specific Python version they distribute; if you manage to alter that version, "on your head be it" -- neither your OS supplier nor the PSF accepts any responsibility for whatever damage that might perhaps do to your system.

Rather, as other answers already suggested, install any other release you wish "besides" the system one -- why tamper with that crucial one, and risk breaking things, when installing others is so easy anyway?! On typical Mac OS X 10.5 machines (haven't upgraded any of my several macs to 10.6 yet), I have the Apple-supplied 2.5, a 2.4 on the side to support some old projects not worth the bother to upgrate, the latest 2.6 for new stuff, 3.1 as well to get the very newest -- they all live together in peace and quiet, I just type the release number explicitly, i.e. using python2.6 at the prompt, when I want a specific release. What release gets used when at the shell prompt you just say python is up to you (I personally prefer that to mean "the system-supplied Python", but it's a matter of taste: by setting paths, or shell aliases, &c, you can make it mean whatever you wish).

Alex Martelli
+3  A: 

Don't upgrade.

  1. Install ActivePython (which co-exists with others).
  2. Open Terminal
  3. Type python2.6
Sridhar Ratnakumar
Can you give please some more details on ActivePython? What is, what can do, why to use? +1
DrFalk3n
ActivePython is a free distribution of Python from ActiveState. It is exactly same as python.org's installer + extra documentation/tutorials, PyWin32, tcl/tk-8.5 (integrates well with Mac) and more importantly comes with a apt-get like *package manager* called PyPM - http://docs.activestate.com/activepython/2.6/pypm.html
Sridhar Ratnakumar
+1  A: 

The best is to use macports (just like Adam Rosenfield stated on this thread).

If you also use the Python2.5 that also comes from macports you can easily switch between versions using the *python_select*.

# installation
sudo port install python_select

# to switch to python2.5
sudo python_select python25

# to switch to python2.6
sudo python_select python26
Pedro Salgado
+1  A: 

The standard http://python.org install for Mac OSX will happily coexist with the "system python". If you let the installer change your paths, when you run python from a prompt in terminal, it will find the version at

 /Library/Frameworks/Python.framework/Versions/2.6/bin/python

However, this won't interfere with anything that OSX itself does with python, which correctly hardwires the path to the version that it installs.

Andrew Jaffe