Mac 电脑 m2 在终端怎么把python3加入环境变量

发布时间 2023-09-12 18:04:00作者: 张仁国

首先获得python3安装路径:

which python3

 

然后编辑 bash_profile 文件

vi ~/.bash_profile

在insert模式下 将python3路径写入

PATH="/Library/Frameworks/Python.framework/Versions/3.11/bin:${PATH}"
export PATH
alias python="/Library/Frameworks/Python.framework/Versions/3.11/bin/python3"

esc,然后:wq,保存并推出。

 

设置python3为默认:

在命令行输入:

source ~/.bash_profile

 

 

vim ~/.zshrc

 

 

source ~/.bash_profile