Mac中默认安装了Python2.7版本,然后当你再次安装Python其他版本,在命令中查看电脑的默认版本依然是2.7

我再本机安装3.8,怎么才能默认使用我安装的版本?

首先在命令窗体中打开bash_profile文件
open ~/.bash_profile
修改bash_profile内容
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8"
保存文件
source .bash_profile
然后执行Python命令
显示的就是你安装的版本啦
网友评论