8

Currently running Mac OS X Lion 10.7.5 , and it has python2.7 as default. In the terminal, i type 'python' and it automatically pulls up python2.7. I don't want that.

from terminal I have to instead type 'python3.2' if i want to use python3.2.

How do i change that?

Hovanky
  • 303
  • 1
  • 3
  • 15
  • As a note, ``python3`` should also work fine, which is a little easier to type, if not a solution. You might run into issues on OS X with the presumption being ``python`` will be linked to ``python2`` - generally [where that link is pointed is down to the distribution](http://www.python.org/dev/peps/pep-0394/), and kept consistent internally, so changing it might cause breakage. – Gareth Latty Nov 12 '12 at 00:11
  • 2
    shouldn't this be on superuser? – loopbackbee Nov 12 '12 at 00:29
  • Don't think so as it's more related to python than terminal. – Captain Anonymous Sep 02 '17 at 12:14

3 Answers3

18

The safest way is to set an alias in ~/.bashrc:

 alias python=python3

That way you avoid breaking things for scripts relaying on python being python2.

mata
  • 67,110
  • 10
  • 163
  • 162
4

You could edit the default python path and point it to python3.2

Open up ~/.bash_profile in an editor and edit it so it looks like

PATH="/Library/Frameworks/Python.framework/Versions/3.2/bin:${PATH}" export PATH

Dave Zych
  • 21,581
  • 7
  • 51
  • 66
CodeMonkey
  • 41
  • 1
3

If you have python 2 and 3 on brew. Following worked for me.

brew unlink python@2

brew link python@3 (if not yet linked)

Noby Fujioka
  • 1,744
  • 1
  • 12
  • 15