On my OS X typing /usr/bin/python in to terminal runs Python 2.6.1, but typing python runs Python 2.7.2. I'd like the former to run 2.7.2 as well - how do I do this?


The version in /usr/bin/python is the version installed as part of OS X. Type 'which python' to find out where your newer python version is located. You've probably installed a newer version via MacPorts or the like.

It might be dangerous to change where /usr/bin/python points to in case it is needed by other apps. You can change your python scripts so that they find the user's version of python by changing the first line from:



#!/bin/env python

If you really want to replace /usr/bin/python, you can do it like this:

sudo mv /usr/bin/python /usr/bin/python.dist
sudo ln -s `which python` /usr/bin/python

However, like I said, that might be dangerous. If you need to revert this change later you can run:

sudo rm /usr/bin/python
sudo mv /usr/bin/python.dist /usr/bin/python

Please run these with care though. If you accidentally remove your system installed python version on OS X there will be some pain involved in getting it back.

  • 1
    Agreed. Also, future updates from Apple may replace the symlink and effectively revert the change, or possibly (depending on exactly how the installer works -- I haven't tested) follow the symlink and replace the 2.7.2 version you've built with something else. May 26 '12 at 0:36

It seems the /usr/bin/python is the Apple provided file. As others mentioned, do not touch it.

The file itself seems to be pointing to (Reference 1):


In this folder you should be able to find the latest installed 2.x or 3.x versions with symbolic link folder named Current/, where Current/ will point to the latest installed version.

Note, all the Python version that you have ever installed are placed in (Reference 2):


In my case I had to remove 2.5 folder from 'Reference 1' and upload 2.7 from 'Reference 2'. Then I removed the 'Current' link and created a new one pointing to 2.7/ folder (ln -s 2.7/ Current). [I am not sure, the same might be needed for the other folder]

Now, when typing python --version you should see python version pointing to the latest Current/ link that you created, in my case it was Version 2.7.

I hope this helped, it worked here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.