Make python3 as default python version in Mac

Python3 has been the default version since python2 has sunset from January 1, 2020.
https://www.python.org/doc/sunset-python-2/

While you install python in your machine, most likely you will get python and python3 . It may seem like troublesome if we need to specific python , one of the solution is to use alias in your shell.

PROFILE

vi ~/.profile
alias pip=pip3
alias python=python3

After you edit the file, do a source ~/.profile

ZSH

vi ~/.zshrc
alias pip=pip3
alias python=python3

After you edit the file, do a source ~/.zshrc

BASH

vi ~/.bashrc
alias pip=pip3
alias python=python3

After you edit the file, do a source ~/.bashrc

Pyenv

Or you can use pyenv to manage the python version.

brew update
brew install pyenv

Do take note if you are using windows, please consider using @kirankotari’s pyenv-win fork. (pyenv does not work on windows outside the Windows Subsystem for Linux)

Validation

That’s it! You have made python3 as default version on Mac!

Stay safe and healthy! Till next time~

Reference from stack overflow

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store