因为笔者有过更改java环境变量的经历。应该原理类似。
问题:
输入python,进入的是python2的环境
EthanNideMacBook-Pro:~ candy$ python
Python 2.7.10 (default, Aug 17 2018, 19:45:58)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
exit()
EthanNideMacBook-Pro:~ candy$ which python3
/usr/local/bin/python3
更改环境变量
网上查资料得知,需要更改~/.bash_profile文件,
不过ls -al下,该文件夹没有当前用户下的该文件,
touch .bash_profile 新增该文件,
进而通过open .bash_profile指令编辑,
熟悉linux vi命令的可以直接编辑。加入下面两行。保存。
EthanNideMacBook-Pro:~ candy$ cat .bash_profile
export PATH=${PATH}:/usr/local/bin
alias python="/usr/local/bin/python3"
source .bash_profi