Mac 终端默认启动python3环境

1. 终端打开.bash_profile文件

终端输入:open ~/.bash_profile

如果提示没有这个文件,可以手动创建或者用命令行创建

$ cd ~/
$ touch .bash_profile
$ open -e .bash_profile

2. 打开.bash_profile文件后在内容最后添加 

alias python="/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6"

alias python2="/usr/bin/python2.7"

alias python="输入python3的路径 你自己本机路径可通过终端输入 which python3 查找" 

alias python2="输入python2的路径 你自己本机路径可通过终端输入 which python2.7 查找"

以后如果使用2.7的路径,只用在终端输入python2

3. commond+R保存

保存后终端中重新读取.bash_profile文件

终端输入:source .bash_profile

4.终端输入python此刻可以发现 已经默认打开python3环境了

jason-macbook-pro:~ wangying$ python2
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
jason-macbook-pro:~ wangying$ python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值