macOS 安装 Python 3
Python 2 已经退出了历史舞台,所以我们的教程都是 Python 3 版本的。
检查 Python 3 是否安装
如果你正在使用比较新的 MacBook 的电脑,系统默认是已经安装了 Python 3 。快捷键 “Command + 空格” 调出搜索框 输入 term 打开终端,检查是否安装了 Python 3:

在终端里面输入 Python3,出现下面提示就说明安装 Python3 了:
Last login: Mon Jul 7 09:08:59 on console
~ ❯ python3
Python 3.9.6 (default, Apr 30 2025, 02:07:17)
[Clang 17.0.0 (clang-1700.0.13.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
在 macOS 中,有两种方式安装 Python3 。
安装方法一
从官网下载 Python 3 macOS 版的安装程序,下载地址为:https://www.python.org/downloads/macos/,下载最新稳定版本 Stable Releases 即可 。

下载后你会得到一个 .pkg 结尾的文件, 双击运行并安装,它会自动推荐到环境变量,所以一直默认即可。安装后按照前面的检查方式打开终端 输入 python3 看是否安装成功。
安装方法二
使用 macOS 的包管理器 Homebrew 安装, Homebrew 官网地址:https://brew.sh/zh-cn/, 简单了解下 Homebrew 包管理器。
“Command + 空格” 输入 term 打开终端,输入 brew ,如果提示 zsh: command not found: brew 则需要安装 Homebrew。
# 安装 Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 安装 Python3
~ ❯ brew install python3