views:

58

answers:

1

Why is there so many Pythons installed in /usr/bin for my Snow Leopard? What decides which one is the System Python?

When I simply type "python" it is 2.6.1 ~ but this doesn't seem to be the "System Python", why not? How does one change system Python and what are the drawbacks?

+2  A: 

My snow leopard only has python 2.5 and 2.6 installed, so it's not that many. You may have additional pythons installed (i.e. python3.0), either system wide (in /usr/bin/) or through macports (/opt/local).

The default system python is defined through a setting,

defaults write com.apple.versioner.python Version 2.5

will change the default to 2.5. You can also use an environment variable, i.e. for bash:

export VERSIONER_PYTHON_VERSION=2.5

All of this is documented in the python manpage,

man python

Overall, it's better not to change the system default. It's what OSX may depend on for certain scripts, and you never know if these scripts work as expected on different versions. Especially Python 3 is different, and may really break your whole system.

If you want a different python to be used for your own scripts, either

  1. Use virtualenv (always good)
  2. Change your PATH and make sure your preferred python is included before the /usr/sbin one
  3. Be explicit, invoke the script using /my/preferred/python
Ivo van der Wijk
That only affects `/usr/bin/python`. A more important factor is what is in your shell search path, `PATH`. For instance, by default, python.org installers attempt to modify your shell startup files to ensure that the python.org framework bin is first in `PATH`.
Ned Deily
I only have 2.5 and 2.6 as well ~ I'd prefer if my default is 2.6. How does one check which one is default? PyGame complains that system python is not 2.6 ~ that's my main issue.
Deniz