1.homebrew安装python3
brew install python3
2.在bash_profile中配置PATH
open ~/.bash_profile
(TIPS:确定python3路径先键入:)
which python3
3.修改路径
export PATH=${PATH}:/usr/local/bin/python3 (which python3中显示的路径)alias python="/usr/local/bin/python3" (重命名操作)
4.保存退出
执行
source ~/.bash_profile
5.bash下的配置操作到此结束
由于macOS Catalina之后默认配置的Shell是zsh
若在zsh环境下使用需要再次配置
使用vim命令打开:
vim ~/.zshrc
写入:
source ~/.bash_profile
即每次打开zsh窗口执行bash_profile以覆盖路径
esc + :wq(保存退出)
后再次键入
python --version
即可查看修改后默认为python3