1痒钝、安裝python3
$ brew search python
$ brew install python3
這里安裝完后不需要單獨(dú)添加環(huán)境變量秉颗,程序已經(jīng)處理好,可以直接運(yùn)行python3命令送矩。
$ which python
/usr/bin/python
$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
2蚕甥、安裝REPL插件,并設(shè)置快捷鍵綁定栋荸。
打開后菇怀,搜索 SublimeREPL 安裝即可。
設(shè)置快捷鍵:
Preferences -> Key Bindings
[
{"keys":["f1"],
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"}},
{"keys":["f2"],
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command", "args":
{"id": "repl_python",
"file": "config/Python/Main.sublime-menu"}}
]
這里我設(shè)置的 F1 運(yùn)行代碼晌块,F(xiàn)2 打開終端爱沟。
3、按 F2 運(yùn)行終端匆背,發(fā)現(xiàn)默認(rèn)集成的是 python2呼伸,手動改成 pyhton3,方法如下:
$ sudo find / -iname 'Main.sublime-menu'
$ vim /Users/keithtt/Library/Application\ Support/Sublime\ Text\ 3/Packages/SublimeREPL/config/Python/Main.sublime-menu
"cmd": ["python3", "-i", "-u"],
"cmd": ["python3", "-i", "-u", "-m", "pdb", "$file_basename"],
"cmd": ["python3", "-u", "$file_basename"],
"cmd": {
"osx": ["python3", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
"linux": ["python3", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
"windows": ["python3", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"]
},
將該文件中調(diào)用 python 命令的地方全部改成 python3 即可钝尸。
改完之后再次按 F2 運(yùn)行終端括享,效果如下: