怎样在mac终端输入python后默认打开python3

正常情况下mac终端输入python会显示Python 2.7

zhangxue@192 ~ % python

WARNING: Python 2.7 is not recommended. 
This version is included in macOS for compatibility with legacy software. 
Future versions of macOS will not include Python 2.7. 
Instead, it is recommended that you transition to using 'python3' from within Terminal.

Python 2.7.16 (default, Feb 29 2020, 01:55:37) 
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.

若想在mac终端输入python后默认打开python3

  • 在终端输入
which python3

在这里插入图片描述

  • 在终端输入
vim ~/.bash_profile
  • 按 i 或 a 进入编辑模式,然后输入
alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3"
  • esc退回正常模式,然后输入 :wq 进入命令模式
  • 在终端输入
source .bash_profile
  • 在终端编辑 zsh 的配置文件/.zshrc
vi ~/.zshrc
  • 按照上述方式在zshrc文件中加入
source .bash_profile
  • 返回终端输入python
zhangxue@192 ~ % python
Python 3.8.3 (v3.8.3:6f8c8320e9, May 13 2020, 16:29:34) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
  • 5
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值