Mac Python升级

334 阅读1分钟
  • 强烈建议不要直接sudo ln -s (会直接覆盖系统原来的link导致想调用自带python的软件出现问题),修改path variable虽然比较安全,但对于你的需要是没有太大必要的。

  • 升级步骤:

  1. 官网下载需要用到的版本 www.python.org/ 安装

  2. command + shift + G 输入 ~ 符号回车 找到 .bash_profile 双击打开

  • 如果没有 .bash_profile 则使用命令行自行添加:(有文件的跳过)
1)cd ~

2)touch .bash_profile

3)回到第二步

  1. 添加一下代码
alias python="/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6"
  • command + s 保存

  • 注意: alias python= 后面的路径是你下载安装到本地的路径 下载安装的 Python 版本都在 /Library/Frameworks/Python.framework/Versions 这个路径下 可使用 command + shift + G 进行找到

然后退出退出Terminal 重新打开输入 python --version 就是你指定的版本了