This question already has an answer here:
-
Issue with Sublime Text 3's build system - can't get input from running program [duplicate]
1 answer
Is it possible to set up sublime text for full stack python development. By this, I mean the following:
1. python shell where I can input an expression and instantly get the result,
2. the shell will work for the 'input' method, which will prompt the user to enter data.
I have installed the theme and color scheme, but the console/shell is not working or I did not get the correct package from the package control. I want an environment where I can work in the sublime text without shifting into the IDLE. Please help me kindly if you know how to do it.
There are several ways to do this:
As @cricket_007 states you can install SublimeREPL and run the current file via Tools >>> SublimeREPL >>> Python >>> Python - Run current file
. This interprets the python file in a Sublime Text view and inputs are possible. However since this is not a build system you can create a build system from this (click Tools >>> Build System >>> New Build System...
and paste):
{
"target": "repl_open",
"encoding": "utf8",
"syntax": "Packages/Python/Python.tmLanguage",
"extend_env": {"PYTHONIOENCODING": "utf-8"},
"type": "subprocess",
"cmd": ["python", "-u", "$file"],
"cwd": "$file_path",
"external_id": "python",
"selector": "source.python"
}
As an alternative one could run the file in a terminal, by using the following build system. This will create a new terminal and execute the file in python and afterwards await pressing enter.
{
"selector": "source.python",
"windows": {
"shell_cmd": "start \"$file_name\" cmd /c \"python $file_name & pause\""
},
"linux": {
"shell_cmd": "xterm -T \"$file_name\" -e bash -c \"python $file_name; echo Press enter to exit... & read\""
}
}
Feel free to add the osx option