Rook Rook - 26 days ago 5x
Python Question

Issue with Sublime Text 3's build system - can't get input from running program

I'm trying to get Sublime Text 3 (build 3049, if that matters) to run a Python script. A simple two liner

var = raw_input("Enter something: ")
print "You entered ", var

which asks for input, waits for it, then prints it out in windows console prompt.

This is, seeing the number of similar questions on the side, a problem for quite a number of users, so I went through those and tried ... stuff. Made a copy of file, commented that one line, made a new pythonw build file, tried messing about with the build file ... nothing seems to work.

In lack of a definite solution, how do you work with Python using Sublime Text 3?


First off, since you're using a dev build, you must be a registered user (good!) and I'd recommend upgrading to 3053, the latest version, as newer is often better in terms of known issues being fixed. Second, just FYI, there's a fairly complete set of (unofficial) docs at They're well-organized, pretty up-to-date, and cover a lot more ground than the "official" ones on Finally, in response to your comment, Sublime comes with a slightly stripped-down version of Python built-in. ST2 has 2.6, while ST3 has 3.3, so if you write plugins you'll need to conform to those language specifications. You can run arbitrary commands from the console by hitting Ctrl`.

As documented in several SO questions, Sublime Text on its own cannot handle input via raw_input() or input(). The same is true of other languages as well - Ruby's gets, Java's Scanner class, Node's readline class, etc. The easiest short-term solution is to get Package Control if you don't already have it, then install SublimeREPL. It allows you to transfer or run part or all of your code through the running REPL (you'll need to start one first).

If the code you're running doesn't play well with SublimeREPL (for instance, you're using C/C++/Java/etc. and need to compile code before it runs), or you just want to run it independently of Sublime, you'll need to make your own build system. Save the following as Packages/User/Python_cmd.sublime-build:

    "cmd": ["start", "cmd", "/k", "c:/python27/python.exe", "$file"],
    "selector": "source.python",
    "shell": true,
    "working_dir": "$file_dir"

changing the path to your Python executable as appropriate. Then, go to Tools -> Build System and select Python_cmd, and when you hit CtrlB to build, a new cmd window will open up with your file running. The /k option returns to the command prompt, without closing the window, after your program is done running so you can examine output, tracebacks, etc.