Mac users strongly recommend using Homebrew to install software. For Python, downloading directly from the official website will create both IDLE and Python Launcher icons in Launchpad, which I personally find ugly.

Actually, macOS Catalina comes with Python 3 pre-installed (Python 2 before that). If you only need to handle basic Python functions, you can just use the system’s built-in version. However, for the convenience of version control, it’s highly recommended to use Homebrew to download another version for easy management, avoiding impacts to the system’s Python.

Installation Steps

  • First, you need to install Xcode Command Line Tools, which Homebrew depends on to work properly. You can enter the command directly in the terminal. Git also gets installed together with this, but for the same reason, it’s still recommended to use Homebrew to install another version of git.

    xcode-select --install
    
  • Install Homebrew:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    

    You may need to enter your password.

  • Verify installation and update to the latest version:

    brew -v
    brew update
    
  • Install Python:

    brew install python
    

    You may now have two Python versions in the system. We need to specify which Python to use:

    which python3
    /usr/bin/python3	# This means you're still using the system's built-in python
    

    Let’s find the location of the Python installed by Homebrew:

    brew --prefix python
    /opt/homebrew/opt/[email protected]
    

    Open the environment variable configuration file. After macOS Catalina, the default shell is zsh:

    vim ~/.zshrc
    

    Add this line at the end:

    export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
    

    Save and refresh the file:

    source ~/.zshrc
    

    Then check which Python version you’re using:

    which python3
    /opt/homebrew/opt/[email protected]/bin/python3	# Homebrew version
    
  • Install git:

    brew install git
    

    Verify the installation:

    git -v
    

    Generally, git won’t have the same PATH setup issues as Python.

  • Configure git’s email and username. If you want to use GitHub to manage your repository, keep this email and username consistent with your GitHub account.