Answer the question
In order to leave comments, you need to log in
How to run Python-a code in Sublime Text 3?
I am writing Python code in Sublime Text 3, but to check how the program works, I need to run the program through the console.
Tell me how to run python code through this editor.
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
There are many options, the first one is ctrl + b, but it doesn't support input. Therefore, I advise you to use SublimeRELP, it is not so difficult to install it, just use Package Control -> Install Package -> SublimeRELP. Now you can Tools -> SublimeRELP -> Python -> Run Current file. But this only supports Python2.7 and is not convenient to use. In order to fix all this, open Preferences -> Key Bindings -> User and add this:
{ "keys": ["ctrl+b"], "command": "repl_open",
"caption": "Python - RUN current file",
"id": "repl_python_run",
"mnemonic": "d",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python3", "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
And what is your python, the third one? For it you need to create a Build System:
{
"cmd": ["python3", "$file"]
}
forum.sublimetext.ru/index.php?topic=558.0
Tools -> build system -> python
CTRL+B (after saving the file)
input will not work,
you can create your own Build System if the default one is not suitable.
my version for pearl and ST2 (in ST3 everything is exactly the same). I think you can rewrite for python - noize85.blogspot.ru/2013/04/sublime-text-2-perl.html
After executing CTRL+B
It is necessary to Stop the process,
what is the quick command for this?
Just execute the file in terminal/command line.
Command: /usr/bin/python3 "path to file."
PS I checked on Linux, there is no Windows, so the command may not work on Windows.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question