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"

Mac 终端默认启动python3环境_第1张图片

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.
>>> 

 

 

你可能感兴趣的:(python3)