0

I use sublime text 3 to code my python script in OSX. However, whenever I create a new python script using sublime text 3, it automatically created the file in Python2.7. But I want to use Python 3.6. This is really annoying and sabotaging my working progress...

Is there any way to change the default path for Python in sublime text 3? Appreciated!!

ryan9025
  • 267
  • 6
  • 17

2 Answers2

0

on mac os terminal type:

$ which python3

Add the path to cmd key of json in .sublime-build file

Adarsh
  • 3,273
  • 3
  • 20
  • 44
  • where to find the json in .sublime-build file? – ryan9025 Oct 29 '17 at 06:46
  • In sublime text go to Tools > Build System if you see python there, click on Build and see the output in the console below. This will give you the overview of whether sublime text 3 is picking up the python3 installation of your device. if you get something like python2.7 or so click on new build system and create a new build using the json as described earlier. next time you run your program, use this build system and all should work fine. But sublime text 3 should support python3 out of the box.Just check if python3 path is added to system path before doing the above – Adarsh Oct 29 '17 at 07:00
0

Just to expand on what was previously said. After you find the path of Python3 with the which command;

  • go to Tools--> Build System --> New Build System and paste the below into the file.

  • Replace PATH_TO_YOUR_PYTHON3 with your python3 path and save as "Python3.sublime-build". Now, Python3 should be an option to build with.

{
  "cmd": ["PATH_TO_YOUR_PYTHON3", "-u", "$file"],
  "file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
  "selector": "source.python"
}
Seanny123
  • 8,776
  • 13
  • 68
  • 124
DPGraham4401
  • 178
  • 1
  • 12