Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Snow Leopard comes packaged with a version of Python 2.6 that is incompatible with many popular libraries, so I've downloaded a version of Python 2.6 from python.org. However, when I type python at the terminal, I still get the old version of Python. How can I change this?

which python currently gives me /Library/Frameworks/Python.framework/Versions/2.6/bin/python

ls -l /usr/bin/python is not a symbolic link to the above (nor to Versions/Current).

I have a version at /opt/local/bin/python2.6 that I wish to be using.

share|improve this question
    
My Snow Leopard shows python --version to be Python 2.6.1. What version are you trying to install? I also wonder if somehow changing this would also affect commands like xattr, for which file /usr/bin/xattr yields /usr/bin/xattr: python script text executable? – Arjan Dec 18 '10 at 17:10
    
I have a version at "opt/local/bin/python2.6" that I wish to be using. I am unsure as to how that would affect commands like xattr, though.. – coffee Dec 18 '10 at 17:17
    
Is /Library/Frameworks/Python.framework/Versions/2.6/bin/ listed in your PATH? Like shown by echo $PATH (If yes, then changing the PATH might suffice for you.) – Arjan Dec 18 '10 at 19:07
    
@Arjan, Yeah, it is. I haven't even modified the path from the default.. – coffee Dec 18 '10 at 19:17
    
See also Getting PATH right for python after MacPorts install. – Arjan Dec 23 '10 at 10:40
up vote 1 down vote accepted

I don't know how this will affect other usage of Python in OS X, but as currently the OS X Python is listed in your PATH, you just need to change that:

I don't know if it matters, but just for the archives: on my OS X 10.6 (which is an upgrade from 10.4 via 10.5), /Library/Frameworks/Python.framework/Versions/2.6/bin/ is not listed in PATH. Instead, which python yields /usr/bin/python.

For example: file /usr/bin/xattr yields /usr/bin/xattr: python script text executable, and hence might be affected by changing the Python executable!

share|improve this answer
    
Ah! So looking at ~/.profile, it seems that Macports added that folder to my path. I commented that out, and it is pointing to the correct python version now. Thanks again for all of your help, Arjan. – coffee Dec 18 '10 at 19:36
    
@coffee, what do you mean by "the correct python version"? Taking it out of the PATH will make OS X use /usr/bin/python, not your new /opt/local/bin/python2.6, right? – Arjan Dec 18 '10 at 19:38
    
nope, it's using the one in /opt/local/bin/... I'm assuming that is listed earlier on the path. – coffee Dec 18 '10 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .