【环境】mac bash终端
一、 设置默认python为python3.6
# 修改/etc/下的profile文件,加入以下内容:
if [ -f ~/.bashrc ] ; then
. .bashrc
fi
# 这样就不用每次启动bash 终端时都要重新source .bashrc文件了
# 1,查看python3安装目录
$ which python
$ which python3
# 2,修改配置文件bashrc,连接python关键词到python3
# 2.1 进入到 /Users/你的用户名 目录
$ cd ~
# 2.2 打开bashrc文件(注意不是同名的文本文件或其他文件,没有的话就手动创建一个),并手动修改
$ open .bashrc
# 2.3 加入以下两行内容
# alias python3='/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6'
# alias python=python3
# 手动保存
# 更新该文件
$ source .bashrc
# 此时输入python,打开的是python3
$ python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more