mac中一般默认安装了Python2,Python3没有安装,这时候一般使用命令:brew install python3 进行安装。 不同方法安装Python的路径是不一样的:
现在将系统默认的Python版本改为3.7:
1.终端输入:
vi ~/.bash_profile
并输入如下代码(PATH以自己本地的Python路径为准):
# Setting PATH for Python 2.7
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Setting PATH for Python 3.7.2
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
2.终端输入:
vi ~/.bashrc
并输入如下代码完成别名的命名:
alias python2='/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'
alias python3='/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7'
alias python=python3
3.最后source一下使其生效:
source ~/.bash_profile 和source ~/.bashrc