macOS zsh配置修改默認python3

1.homebrew安裝python3

brew install python3

2.在bash_profile中配置PATH

open ~/.bash_profile 

(TIPS:確定python3路徑先鍵入:)

which python3

3.修改路徑

export PATH=${PATH}:/usr/local/bin/python3 (which python3中顯示的路徑)

alias python="/usr/local/bin/python3" (重命名操作)

4.保存退出

執行

source ~/.bash_profile

5.bash下的配置操作到此結束

由於macOS Catalina之後默認配置的Shell是zsh

若在zsh環境下使用需要再次配置

使用vim命令打開:

vim ~/.zshrc 

寫入:

source ~/.bash_profile

即每次打開zsh窗口執行bash_profile以覆蓋路徑

esc + :wq(保存退出)

後再次鍵入

python --version

即可查看修改後默認爲python3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章