Mac默認安裝了Python2.7 ,python
python -Vgit
which pythongithub
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"ruby
brew install python3curl
which python3url
pythonspa
import sys3d
sys.pathblog
(能夠看到個人python 2 被自動安裝到:/System/Library/Frameworks/Python.framework/Versions/2.7 )homebrew
exit()
python3
import sys
sys.path
(能夠看到個人python 3 被homebrew自動安裝到:/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7 )
exit
我把全部變量都放到全局環境變量文件/etc/profile中了,因此是在這裏修改python的默認路徑。若是你的變量是自定義文件,就去那個自定義文件裏修改吧。
sudo vi /etc/profile
:wq! 保存新增變量
更新全局配置文件:source /etc/profile
查看新增變量 : echo $PYTHON_3_PATH
固然若是你想不定義變量就直接修改默認python版本也能夠:
alias python='/usr/local/bin/python3'
便可。
若是想改回python2就:alias python=$PYTHON_2_PATH