Search code examples
pythondjangobashmacosterminal

How to switch Python versions in Terminal?


My Mac came with Python 2.7 installed by default, but I'd like to use Python 3.6.1 instead.

How can I change the Python version used in Terminal (on Mac OS)?

Please explain clearly and offer no third party version manager suggestions.


Solution

  • The simplest way would be to add an alias to python3 to always point to the native python installed. Add this line to the .bash_profile file in your $HOME directory at the last,

    alias python="python3"
    

    Doing so makes the changes to be reflected on every interactive shell opened.