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?

3
  • 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, and kept consistent internally, so changing it might cause breakage. Commented Nov 12, 2012 at 0:11
  • 2
    shouldn't this be on superuser? Commented Nov 12, 2012 at 0:29
  • Don't think so as it's more related to python than terminal. Commented Sep 2, 2017 at 12:14

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you! Also, alias python=python3 didnt work but alias python = python3.2 did work.
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

1 Comment

I think that the first option is much simpler and more effective.
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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.