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
原文:https://www.cnblogs.com/hrv5/p/12212930.html