MacOS – Is an older version of Python a necessity

macospython

ML 10.8.4 and I have installed Python 2.6, 2.7 and 3.3. I keep reading that it's necessary to keep the the 2.6 version around because the system uses it. However, I've not found any software that needs it other than that which I installed (and I can control which version THAT needs – I complied and installed SciPy for 3.3.2 for example). So, using macports I pointed the python link to the 3.3.2 install to see if there is something hidden that I've missed. I've not had any problems.

So I'm wondering if it's even necessary to keep the old versions around. I am aware that this will limit certain versions of python scripts that I install.

Does anyone know what I definitively will break by having python link to 3.3.2 in a base install of ML?

Also, I suspect that the 2.6 version is an old hanger on from Snow Leopard (machine migration) as supposedly, ML uses 2.7. But I can't confirm that.

Best Answer

While there are obviously differences in the different versions of Python, there are also differences between the "system" Python and those you install via Python.org, MacPorts, Homebrew, etc. All of these "additional" versions can coexist quite happily with the system versions in /System/Library/Frameworks/Python.framework/Versions - I have 2.3, 2.5.6, 2.6.7, and 2.7.2 on my 10.8.4 iMac which originally came with Lion installed. /usr/bin/python is 2.7.2.

Basically, there is no good reason to get rid of any of the system Pythons (they only take up ~200MB), and some very good reasons to not get rid of them. They are included for a reason, and there are various system utilities and programs that depend on them. You could get strange, unexplained behavior if you remove them, and vital stuff may not work, as Python scripts and libraries are behind some major system tools. Python has been designed to have multiple versions living happily side-by-side, so if your system is set up properly (which I generally trust the Apple engineers to have done), there won't be any conflicts as hypothesized by another answer.

If you want to change which version of Python runs by default when you type python into the Terminal prompt, then change your $PATH environment variable to point toward your installation of choice, do not unlink or change /usr/bin/python. For example, I use MacPorts, so /opt/local/bin is ahead of /usr/bin in my $PATH, so I never run the "system" version 2.7.2. You can then start your scripts with

#!/usr/bin/env python

and it will search your path for the correct binary.

You should have no problems at all using MacPorts point to your version of choice. One thing I would suggest, though, is to keep /opt/local/bin/python pointing to the latest version of Python 2 (2.7.5, currently), and use /opt/local/bin/python3 point to 3.3.2. Yes, you have to remember to add the 3 on the end of the command, but several months back I tried setting python to Py3, and occasionally would get weird errors from some programs expecting Py2 to be there.

Hopefully this helps answer your actual question, please let me know if you need anything else.