0
点赞
收藏
分享

微信扫一扫

Mac安装python3并配置环境变量


文章目录

  • ​​homebrew 安装 python3​​
  • ​​配置 python3 环境变量​​

homebrew 安装 python3

可以用 homebrew 安装,也可以官网下载安装,我这里选择使用 homebrew 安装,没有装 homebrew 的小伙伴请自行百度

brew install python3

我们执行下 python3 发现可以识别命令了

配置 python3 环境变量

先看下 python3 安装路径,因为我的 homebrew 是路径为 ​​/opt/homebrew​​ 小伙伴可以自己找寻自己的 homebrew 安装的路径哈

然后我们找到 python3 的具体安装路径

ls -al /opt/homebrew | grep python3

Mac安装python3并配置环境变量_python


很容易知道我的 python3 的路径是在:

​/opt/homebrew/Cellar/python@3.10/3.10.9/bin​

于是打开 zshrc 文件把 python3 环境变量配置其中(大家注意配置自己的路径)

# Python3 环境变量配置(from homebrew)
PYTHON_HOME=/opt/homebrew/Cellar/python@3.10/3.10.9
PIP_HOME=/opt/homebrew/Cellar/python@3.10/3.10.9
PATH=$PYTHON_HOME/bin:$PIP_HOME/bin:$PATH
export PYTHON_HOME
export PIP_HOME
export PATH

最后我们检查一下

which PYTHON_HOME


举报

相关推荐

0 条评论