It’s not possible with core Sublime to run an interactive program such as this directly within Sublime. The build process is more for running programs than interacting with them, so there’s nothing that connects the input of your program to anything in Sublime.
The net result is that once your program hits the input
, it’s effectively hung forever waiting for you to provide input that you can’t give it.
One solution is to use use SublimeREPL to run interactive python scripts from directly within Sublime, although this requires some setup.
Alternatively, you can select Tools > Build System > New Build System...
, then replace the contents of the buffer with the following and save it as "Xterm_Python.sublime-build` (or some similar name):
{
"shell_cmd": "xterm -e 'python -u \"$file\" ; echo \"<RUN COMPLETE>\" && read'",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
}
Once it’s saved, go to Tools > Build System
and choose the build; it will appear in the menu with the same name as you gave the file above.
Now when you build, an external xterm
window will be opened and the program will run in there. When it’s finished, press Enter to close the xterm
window and return to Sublime.