1. 安装
步骤 1:下载 Python 3.12 安装包
- 访问 Python 官网 打开浏览器,访问:https://www.python.org/downloads/
- 选择 macOS 版本
页面会自动检测你的系统,显示 macOS 下载按钮。
或者手动选择:
- 点击'Download Python 3.12.x'(当前最新稳定版)
- 或访问:https://www.python.org/downloads/macos/
- 文件名类似:
python-3.12.x-macos11.pkg - 文件大小:约 50-60 MB
选择正确的安装包 对于现代 macOS(10.9+),下载:
macOS 64-bit universal2 installer (.pkg)
例如:选择最新的稳定版本(如 Python 3.12.x),下载 .pkg 安装包。
步骤 2:安装 Python 3.12
- 双击安装包
在「下载」文件夹中找到下载的
.pkg文件,双击打开。- ✅ Install shell profile:创建命令行配置文件
- ✅ Add Python to PATH:将 Python 添加到系统路径(非常重要!)
- 安装位置:默认
/Library/Frameworks/Python.framework/Versions/3.12/
- 等待安装完成 安装过程大约需要 1-2 分钟。
运行安装向导 按照提示一步步进行:
1. 欢迎界面 → 继续
2. 许可协议 → 继续 → 同意
3. 安装类型 → 推荐选择"安装",保持默认位置
4. 重要:勾选「Install shell profile」和「Add Python to PATH」
5. 输入管理员密码确认
步骤 3:验证安装
- 打开终端
- 按
Cmd + Space搜索「终端」或「Terminal」 - 或打开「应用程序」→「实用工具」→「终端」
- 按
检查安装位置
which python3.12 # 应该显示:/Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
which python3 # 应该显示:/usr/local/bin/python3(符号链接)

