Installation

On most systems you can end up with multiple versions of Python installed and this can be confusing. We're going to set it up once so that we're using the latest version (3.10 or 3.11 at the time of this writing) and only that version.

You cannot avoid having multiple versions of Python installed because older Macs and Linux distributions come with version 2.7 installed by default so you might see this:

$ python --version
Python 2.7.16

It's important to note that Python 2.x is a really really old version of Python, more than 10 years old. You never want to use it and most of what we're writing won't work in Python 2.7.

Install Python 3:

Homebrew will install 3.10 by default instead of 3.11, this is fine.

brew install python3
which python3
python3 --version

On Ubuntu, you should already have a reasonably recent version of Python installed. Check your version with:

python3 --version

Set Up the python Alias

Open your shell's configuration file, for zsh:

code ~/.zshrc

and paste this at the bottom:

alias python=python3

Close your terminal window and open a new one. In any new terminal window from this point you can now just type python instead of python3.

which python
python --version

Last updated