怎么讓mac終端輸入python默認打開python3


mac自帶python2,終端輸入python后,顯示如下:

linfangdeair:~ linfang$ python
Python 2.7.10 (default, Feb 22 2019, 21:55:15) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

然而,如何將mac默認打開python3呢?

***  1. 終端打開.bash_profile文件  ***
open ~/.bash_profile

***  2. .bash_profile文件內容  ***
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

# 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


***  3. 添加別名->最終文件  ***
alias python="/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6"

***  4. 終端中重新讀取.bash_profile文件  ***
source .bash_profile

再次在終端輸入python,結果如下:

linfangdeair:~ linfang$ python
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

-------------------------------------------------------------------------------------------------------------------------------------

轉載自https://blog.csdn.net/monkey7777/article/details/52295611


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM