Mac终端默认打开python3

266 阅读1分钟

Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑向下兼容。

Mac自带python2,终端输入pythonpython --versionpython -V即可查看版本

Python3 最新源码: Python 官网:www.python.org/ Python文档下载地址:www.python.org/doc/

先看下Python安装地址: which python 输出:/usr/bin/python 注意:这是python2 的命令地址

  1. python 3的命令地址: which python3 输出: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3

  2. 终端打开.bash_profile文件 open .bash_profile

.bash_profile文.png

3.添加别名:在文件最后添加alisa

alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3"

变成了:

添加alisa.png

command+s保存

4.终端中重新读取.bash_profile文件 source .bash_profile

最后,在终端中输入python

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.