Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OSX: Switch to Python 2.7.3

I've installed the Mac OSX Python 2.7.3, and tried switching to the new version:

$ python2.7 -V
Python 2.7.3         # It was installed
$ python -V
Python 2.6.1         # Default is 2.6
$ export VERSIONER_PYTHON_VERSION=2.5
$ python -V
Python 2.5.4         # I can switch to 2.5
$ export VERSIONER_PYTHON_VERSION=2.6
$ python -V
Python 2.6.1         # And 2.6

But:

$ export VERSIONER_PYTHON_VERSION=2.7
$ python -V
python: VERSIONER_PYTHON_VERSION environment variable error (ignored)
Python 2.6.1

Can't switch to 2.7! Why is that?

like image 324
Adam Matan Avatar asked May 04 '12 08:05

Adam Matan


2 Answers

The python.org install will put a python executable in /usr/local/bin . Apple's python is in /usr/bin

To call the python.org python you can use its full path /usr/local/bin/python or change your path to put /usr/local/bin before /usr/bin. You will still be able to call Apple's python by using its full path /usr/bin/python

Some python installs e.g. Macports provide a tool that provides symbolic links to various python installs and allows you to switch between them.

like image 145
mmmmmm Avatar answered Oct 15 '22 23:10

mmmmmm


I don't think we can switch the python version on the Mac OS X without resorting to something like MacPorts or ActivePython.

like image 24
bxio Avatar answered Oct 15 '22 23:10

bxio