首页 > 技术文章 > Mac安装升级python

vivian187 2020-04-16 11:18 原文

1.如果有别的不需要的版本可以卸载,例如卸载3.6,安装3.7

1.1 删除Python 3.6 framework

sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.6

1.2 删除Python 3.6 应用目录

sudo rm -rf "/Applications/Python 3.6"

1.3 删除/usr/local/bin 目录下指向的Python3.6的连接

cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.6' | awk '{print $9}' | tr -d @ | xargs rm

2.安装python3.7

2.1 在官网上下载pkg,点击安装
2.2 检查.bash_profile

open -e .bash_profile // 打开

内容为:

# 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.6的需要删掉,然后

source .bash_profile

推荐阅读