M1 MacOS 切换系统默认Python版本

MX Lv3

安装Python:

brew install python

编辑 ~/.zshrc :

export PATH="$(brew --prefix)/opt/python@<X>/libexec/bin:$PATH"

为python版本,例如:

export PATH="$(brew --prefix)/opt/python@3.10/libexec/bin:$PATH"

使配置生效:

source ~/.zshrc

查看结果:

1
2
3
4
5
6
7
8
9
10
11
% which python
/opt/homebrew/opt/python@3.10/libexec/bin/python

% python --version
Python 3.10.11

% which pip
/opt/homebrew/opt/python@3.10/libexec/bin/pip

% pip -V
pip 23.1.2 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10)
  • 标题: M1 MacOS 切换系统默认Python版本
  • 作者: MX
  • 创建于 : 2023-05-12 15:54:00
  • 更新于 : 2024-11-29 13:41:02
  • 链接: https://www.convolution.fun/2023/05/12/202305121554/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
M1 MacOS 切换系统默认Python版本