TL;DR: The build file is broken and needs to be fixed, because you can’t run a directory, you can only run programs.
The OP’s original problem is two-fold, First, they specified the command to be executed as the folder that the python interpreter is installed in instead of a path to the executable itself, and secondly they used cmd
instead of shell_cmd
. Technically that is not a problem except that it obfuscates what’s going on.
To demonstrate, open the Sublime console with Ctrl+` or View > Show Console
from the menu, and then enter this command and press enter.
window.run_command("exec", {"shell_cmd": "c:\\"})
That tells the window to run the exec
command (which is what executes builds) and tells it to pass a command line of c:\
to the windows command intepreter. The result is a build window popping up, which includes this error:
'c:\' is not recognized as an internal or external command,
operable program or batch file.
Windows is telling us that it can’t find a program named c:\
, which makes sense because that is not a program, that’s the name of a folder on your hard drive.
Now do the same thing but enter this instead:
window.run_command("exec", {"cmd": ["c:\\"]})
This is an alternate way to do the same thing as above, except that where shell_cmd
gives a command line to the windows command interpreter to run it, cmd
directly tells windows “run this program”.
As we already know, this isn’t a program, it’s the name of a folder. However we told windows it was a program and it should try to run it. The resulting build window says this:
[WinError 5] Access is denied
The reason access is denied is because you’re not allowed to run directories, you’re only allowed to run programs.
So, the overall moral of the story is, the OP incorrectly specified in the cmd
that the program to run was the folder where Python is installed, when it should have also included the name of the Python interpreter itself. Thus, windows balks and the build fails.
In order to fix the problem, the sublime-build
file needs to be modified to be correct. The easier thing to do is check the box in the Python installer that tells it to add the Python installer to the PATH. The second easiest thing to do is manually add the appropriate folder to your PATH (use Google to determine how to do that based on your OS). The third easiest thing to do is add a path
key to the sublime-build
file to temporarily augment the path.