Note: This post is a bit older. Paths and Python versions may have changed in the meantime. When in doubt, check the current Brew install (brew info python).

If you’ve installed Python3 on your Mac using Homebrew, you’re likely to run into this issue. When you try to run python, you get an error. Here’s how to fix it.

Using the editor of your choice (mine is vi):

vi ~/.zshrc

Add the following line towards the end of the file:

export PATH="/opt/homebrew/opt/python@3.11/libexec/bin:$PATH"

Save, close the editor, then run:

source ~/.zshrc

From now on, python works directly.