By default, Sublime text uses python command to build a python code and MacOS ships with python 2.7. If you want to use python 3 with sublime text build, first install desired Python 3 package.
To build Python 3 on Sublime text go to Tools-> Build System -> New Build System
Paste the following command:
{
"shell_cmd": "/usr/bin/env python3 ${file}",
"selector": "source.python",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"working_dir": "${file_path}"
}
then save as Python3.sublime-build into /Users/ /Library/Application Support/Sublime Text 3/Packages/User
then open a new file and add the following lines to test python version.
import sys
print (sys.version)
Choose Python 3 build and Ctrl+B
You should see in the bottom of the Sublime text
3.6.3 (v3.6.3:2c5fed86e0, Oct 3 2017, 00:32:08)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
[Finished in 0.4s]