Mac下安装配置Python2和Python3

安装Python2

Mac系统已经默认带有Python2.7了,所以无需安装它。
查看安装路径:which python

安装Python3

brew install python3

which python3

不同版本Python路径

系统默认(2.7)    /System/Library/Frameworks/Python.framework/Versions/2.7
brew安装(2.7/3.x)    /usr/local/Cellar/python
官网pkg安装(3.x)    /Library/Frameworks/Python.framework/Versions/3.x

配置Python2和Python3

~/.bash_profile

PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Setting PATH for Python 3.6.5
PATH="/usr/local/Cellar/python/3.6.5/bin:${PATH}"

———————————————

~/.bashrc

alias python2='/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'
alias python3='/usr/local/Cellar/python/3.6.5/bin/python3.6'
# alias python=python3

source ~/.bash_profile

source ~/.bashrc

 

posted @ 2020-02-21 23:01  haiwei.sun  阅读(217)  评论(0)    收藏  举报
返回顶部