[Python] 如何将Mac python2 升级到python3

401 0
Honkers 2026-6-17 01:25:26 来自手机 | 显示全部楼层 |阅读模式

如何将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.csdn.net/luoyayun361/article/details/81607829
https://blog.csdn.net/hechaojie_com/article/details/82433051

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行