安装 python brew install python@3.11 系统默认版本 python3 --version Python 3.9.6 which python3 /usr/bin/python3 Homebrew 安装版本 python3.11 --version Python 3.11.11 which python3.11 /opt/homebrew/bin/python3.11 编辑 ~/.zshrc 文件,添加以下配置 # 添加 Homebrew Python 路径到 PATH 环境变量最前面 export PATH="/opt/homebrew/bin:$PATH"# 添加别名 alias python=python3.11 alias python3=python3.11 alias pip=pip3.11 alias pip3=pip3.11 source ~/.zshrc ➜ ~ python --version Python 3.11.11 ➜ ~ python3 --version Python 3.11.11 ➜ ~ which python3 python3: aliased to python3.11 ➜ ~ pip --version ppip 24.3.1 from /opt/homebrew/lib/python3.11/site-packages/pip (python 3.11) ➜ ~ pip3 --version pip 24.3.1 from /opt/homebrew/lib/python3.11/site-packages/pip (python 3.11)