美文网首页
Mac 配置多个版本的 python

Mac 配置多个版本的 python

作者: ChenME | 来源:发表于2018-12-27 13:44 被阅读17次
  1. 打开当前用户的根目录下的 .bash_profile 文件,添加 python 的路径,并导出:
PATH=$PATH:"/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"
export PATH
  1. 添加别名,很重要,否则不会有效;
alias py3="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7" # 3.7.2 版本的路径
alias py2="/usr/bin/python" # 2.7.10 版本的路径
  1. 立即生效:
source ~/.bash_profile
  1. 验证是否有效:
py2 -V
py3 -V

分别打印出表示成功

Python 2.7.10
Python 3.7.2

相关文章

网友评论

      本文标题:Mac 配置多个版本的 python

      本文链接:https://www.haomeiwen.com/subject/beerlqtx.html