一、配置python3為系統(tǒng)默認(rèn)版本
1,首先通過which Python查看安裝路徑

上圖為系統(tǒng)默認(rèn)版本路徑,輸入which Python3(版本號),可以查看當(dāng)前版本安裝路徑

2,將python3配置成默認(rèn)使用的版本
打開終端,輸入vi ~/.bash_profile, 按 i 進(jìn)入編輯狀態(tài),添加一行配置:
alias python="/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6"

按ESC和:后,再輸入wq保存和退出。
在終端輸入source .bash_profile 更新文檔
注:如果安裝路徑是:/usr/local/bin/python3.6,只需要更改一下環(huán)境變量的路徑即可
Setting PATH for Python 3.6
The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
alias python="/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6"
python3.8
Setting PATH for Python 3.8
The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3"
python3.7
寫的:alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.7"
3,終端輸入python,就會指向python3

二、配置pip
1,同樣用vi命令編輯bash_profile 文件 。
export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3.7
alias pip="/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3.7"

保存并退出。
2,在終端輸入source .bash_profile 更新文檔
3,在終端輸入pip,就可以得到python3.6下的pip3了。
