python3与python2环境切换

Mac本上安装了python2,然后又安装了python3.需要python3 与 python2之间切换。
配置环境变量:
vim ~/.bash_profile
 
如下内容:
if [ -e ~/.bashrc ]; then source ~/.bashrc; fi
 
# added by Miniconda2 4.2.12 installer
export PATH="/Users/cathy/miniconda2/bin:$PATH"
 
# added by Miniconda3 4.2.12 installer
#export PATH="/Users/cathy/miniconda3/bin:$PATH"
~
 
用python -V查看python版本为python2
 
Mac系统的环境变量,加载顺序为:
/etc/profile /etc/paths ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc
当然/etc/profile和/etc/paths是系统级别的,系统启动就会加载,后面几个是当前用户级的环境变量。后面3个按照从前往后的顺序读取,如果~/.bash_profile文件存在,则后面的几个文件就会被忽略不读了,如果~/.bash_profile文件不存在,才会以此类推读取后面的文件。~/.bashrc没有上述规则,它是bash shell打开的时候载入的。
 
posted @ 2017-07-20 16:01  cathywu  阅读(808)  评论(0编辑  收藏  举报