python - Issue with Sublime Text 3's build system - can't get input from running program -
this question has answer here:
- sublime text 2 console input 2 answers
i'm trying sublime text 3 (build 3049, if matters) run python script. simple 2 liner
var = raw_input("enter something: ") print "you entered ", var
which asks input, waits it, prints out in windows console prompt.
this is, seeing number of similar questions on side, problem quite number of users, went through , tried ... stuff. made copy of exec.py file, commented 1 line, made new pythonw build file, tried messing build file ... nothing seems work.
in lack of definite solution, how work python using sublime text 3?
first off, since you're using dev build, must registered user (good!) , i'd recommend upgrading 3053, latest version, newer better in terms of known issues being fixed. second, fyi, there's complete set of (unofficial) docs @ docs.sublimetext.info. they're well-organized, pretty up-to-date, , cover lot more ground "official" ones on sublimetext.com. finally, in response comment, sublime comes stripped-down version of python built-in. st2 has 2.6, while st3 has 3.3, if write plugins you'll need conform language specifications. can run arbitrary commands console hitting ctrl`.
as documented in several questions, sublime text on own cannot handle input via raw_input()
or input()
. same true of other languages - ruby's gets
, java's scanner
class, node's readline
class, etc. easiest short-term solution package control if don't have it, install sublimerepl. allows transfer or run part or of code through running repl (you'll need start 1 first).
if code you're running doesn't play sublimerepl (for instance, you're using c/c++/java/etc. , need compile code before runs), or want run independently of sublime, you'll need make own build system. save following 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 path python executable appropriate. then, go tools -> build system
, select python_cmd
, , when hit ctrlb build, new cmd
window open file running. /k
option returns command prompt, without closing window, after program done running can examine output, tracebacks, etc.
Comments
Post a Comment