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

背景:mac os x默认安装python2.7,所以虽然后来装了python3.5,但在终端中输入python -V,仍然显示版本号是2.7。 

那么,想在终端中输入python,进入python3的环境要怎么做呢?
***  1. 终端打开.bash_profile文件  ***
open ~/.bash_profile

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

***  3. 添加别名->最终文件  ***
alias python="/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5"

***  4. 终端中重新读取.bash_profile文件  ***
source .bash_profile

此时,在终端中输入python,应该就是python3的环境了。 

注意:添加时,路径的双引号。

原文链接:https://blog.csdn.net/monkey7777/article/details/52295611

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值