Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make python 2.6 my default in Mac OS X Lion?

I just upgraded to lion and with it came Python 2.7. I need to use 2.6 as my default python as the project I primarily work on uses 2.6.

like image 942
mikec Avatar asked Aug 09 '11 15:08

mikec


People also ask

How do I make Python default on Mac?

Open the terminal (bash or zsh) whatever shell you are using. Install python-3 using Homebrew (https://brew.sh). Look where it is installed. Change the default python symlink to the version you want to use from above.

What is the default version of Python on Mac?

x on macOS? If you are a macOS user like me, you know the default version of Python that comes by default with your mac is version 2. X.


2 Answers

Apple has provided two very simple ways to change the default python on OS X 10.6 Snow Leopard and 10.7 Lion. It's all detailed in the Apple man page for python(1):

$ man python
$ which python
/usr/bin/python
$ python -V
Python 2.7.1
#
# temporarily change version
#
$ export VERSIONER_PYTHON_VERSION=2.6
$ python -V
Python 2.6.6
$ unset VERSIONER_PYTHON_VERSION
$ python -V
Python 2.7.1
#
# persistently change version
#
$ defaults write com.apple.versioner.python Version 2.6
$ python -V
Python 2.6.6
like image 187
Ned Deily Avatar answered Oct 01 '22 02:10

Ned Deily


After running the following:

defaults write com.apple.versioner.python Version 2.6

To make sure the packages you install with 'sudo' are installed for the correct Python version, also set the versioner option as a superuser:

sudo su
# Enter password
defaults write com.apple.versioner.python Version 2.6
exit
like image 23
tarequeh Avatar answered Oct 01 '22 03:10

tarequeh