如何将Mac python2 升级到python3
1.下载后双击安装,装到默认的系统位置即可。装完后会自动写入环境变量,打开终端,输入命令:
vim ~/.bash_profile
2.打开后可以在编辑器中可以已经存在了python 最新版本配置,如下
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
3.编辑.bash_profile文件,在最后一行下面添加如下:
PYTHON_HOME=/Library/Frameworks/Python.framework/Versions/3.7
export PATH=
P
A
T
H
:
PATH:
PATH:PYTHON_HOME/bin
alias python=${PYTHON_HOME}/bin/python3
或者 在最后添加一行
alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"
4.保存退出,刷新
source ~/.bash_profile
5.然后查看版本
python --version
指导链接:https://blog.youkuaiyun.com/luoyayun361/article/details/81607829
https://blog.youkuaiyun.com/hechaojie_com/article/details/82433051