首页 > 编程语言 > 详细

怎么让mac终端输入python默认打开python3

时间:2020-01-19 13:01:35      阅读:302      评论:0      收藏:0      [点我收藏+]

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

怎么让mac终端输入python默认打开python3

原文:https://www.cnblogs.com/hrv5/p/12212930.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!