1.终端运行如下命令
vi ~/.bash_profile
2.查看Python 位置
~ which python /usr/bin/python
3.打开该文件之后,在下面添加如下命令行
alias python2='/usr/bin/python' // python2 的地址 alias python3='/Library/Frameworks/Python.framework/Versions/3.7/bin/python3' // python3 的地址
4.保存后运行如下命令使修改生效
source ~/.bash_profile
5.版本
python --version Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43)
source ~/.bash_profile文件失效
解决如下:
使用iTerm 安装了oh-my-zsh之后,就不再会每次开iTerm或者终端的时候,执行默认文件 ~/.bash_profile
而是去执行 .zshrc。
所以要到 .zshrc文件中加上source ~/.bash_profile。
1)进入到用户目录 /Users/用户名 下
2) vim .zshrc
3)在.zshrc最后加入source ~/.bash_profile