iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐍

How to run python3 with the python command on macOS

に公開

Introduction

After installing python3 on macOS, running the python command resulted in an error.

python -v
Error content
zsh: command not found: python

This is because the python command is not linked to python3.
Therefore, you correctly need to run the python3 command as shown below.

python3 -v

However, typing python3 every time is a bit of a hassle.
So, in this article, I will show you how to enable the python command to execute python3.

Solution

You can solve this by following these steps.

1. Check the path

First, check where python3 is installed.

which python3
/opt/homebrew/bin/python3

Create a symbolic link named python pointing to python3.

ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python

3. Verification

Run the python command to verify that python3 is executed.

python -v
Python 3.12.3

Now, you can execute python3 using the python command.

Summary

In this article, I introduced how to make the python command execute python3.
If you use python3 frequently, please give this method a try.

Discussion