Mac同时安装python2和python3

Mac自带的python版本2.7,而2.7的版本默认的字符集是ascii,不支持中文,3的版本默认是utf-8,在使用中会方便很多 

安装套件管理工具homebrew:

localhost:~ mac$ ruby -e "$(curl -fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"

安装后检查一下(我的虽然安装后出现waring提示,但是不影响python3的安装的):

localhost:~ mac$ brew doctor

Please note that these warnings are just used to help the Homebrew maintainers

with debugging if you file an issue. If everything you use Homebrew for is

working fine: please don't worry or file an issue; just ignore this. Thanks!

 

Warning: A newer Command Line Tools release is available.

Update them from Software Update in the App Store.

 

 

Warning: Broken symlinks were found. Remove them with `brew prune`:

 /usr/local/share/man/man8/prlexec.8

安装python3:

localhost:~ mac$ brew install python3

检查python版本:

localhost:~ mac$ python3 –v

Python 3.7.0 (default, Oct  2 2018, 09:20:07)

检查连个python位置:

localhost:python mac$ which python

/usr/bin/python

localhost:python mac$ which python3

/usr/local/bin/python3