Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting python3.2 as default instead of python2.7 on Mac OSX Lion 10.7.5

Tags:

python

macos

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?

like image 804
Hovanky Avatar asked Nov 12 '12 00:11

Hovanky


People also ask

How do I use Python 3 instead of 2 on Mac terminal?

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.


3 Answers

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.

like image 64
mata Avatar answered Sep 21 '22 15:09

mata


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

like image 37
CodeMonkey Avatar answered Sep 19 '22 15:09

CodeMonkey


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)

like image 24
Noby Fujioka Avatar answered Sep 21 '22 15:09

Noby Fujioka