其他_更改mac系统终端里打开python的版本号

系统:mac

python版本:2.73.53.6

 

需求原因:

电脑里安装了python2.7(默认),执行python命令打开

工作需要又安装了python3.5,执行python3可以命令打开

后来装了anaconda,python3启动改成了3.6版本,想要使用python3.5就得执行python3.5 *.py,python3默认打开的是3.6版本,有些头疼

 

解决方法:

打开'~/.bash_profile',在需要默认打开的版本前面加上“alias”,文件保存,终端重启,成功

这时运行python,打开的就是python3.5了,其他python2.7/python3.5/python3.6的命令仍然可以正常使用。

例:alias PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"

 

参考

https://www.zhihu.com/question/30941329/answer/51489517

原文地址:https://www.cnblogs.com/hejianlong/p/9471032.html