Mac中升級Python2.7到Python3.5步驟詳解,python2.7python3.5

來源:互聯網
上載者:User

Mac中升級Python2.7到Python3.5步驟詳解,python2.7python3.5

下載Python3.5 for Mac 一步步安裝

安裝的預設路徑是: /Library/Frameworks/Python.framework/Versions/3.5/

強烈建議不要直接sudo ln -s (會直接覆蓋系統原來的link導致想調用內建python的軟體出現問題),修改path variable雖然比較安全,但對於你的需要是沒有太大必要的。

想要實現你的如下要求

在終端裡直接輸入“python”命令就會運行3.5的py版本?

直接在.profile加一個alias就可以了。如果你的Terminal啟動並執行shell是bash(預設),可以修改~/.bash_profile,添加下行(具體的path取決於你的python3安裝路徑):

複製代碼 代碼如下:
alias python="/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5"

然後重啟一下Terminal或者直接

source ~/.bash_profile

下面的是我的Mac使用者的家目錄中的.bash_profile內容,供參考

alias ls='ls -G' -->ls 帶有顏色的檔案顯示alias ll='ls -l' #unalias ls #unalias ll#export CLICOLOR=1export LSCOLORS=exfxaxdxcxegedabagacad   --->設定的顯示的目錄和檔案的帶顏色的export PATH=$PATH:/usr/local/MySQL/bin:/Library/Frameworks/Python.framework/Versions/3.5/binexport PATH# Setting PATH for Python 3.5# The original version is saved in .bash_profile.pysaveexport PATH=$PATH:/Library/Frameworks/Python.framework/Versions/3.5/bin:alias python="/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5"~   

如果想要Python2.7的就把.bash_profile中的最後一行注釋掉,要用Python3.5.2的就把.bash_proflle的最後一行生效就好,簡單方便,我喜歡。

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.