A
A
Alexey Mistin2015-02-22 13:59:53
Sublime Text
Alexey Mistin, 2015-02-22 13:59:53

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

8 answer(s)
V
Vladisus, 2015-02-22
@Mistin

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"}
                    }
  }

(in square brackets).
Now with Ctrl + b everything should work.

Z
zasqer, 2015-02-22
@zasqer

And what is your python, the third one? For it you need to create a Build System:
{
"cmd": ["python3", "$file"]
}

D
Denis, 2015-02-22
@42molibdenum

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.

N
noize, 2015-02-26
@noize

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

S
sintez, 2015-02-22
@sintez

CTRL+B (CMD+B)

N
nzarchii60, 2020-04-13
@nzarchii60

After executing CTRL+B
It is necessary to Stop the process,
what is the quick command for this?

A
ArboLeet, 2020-09-10
@ArboLeet

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.

1
12q, 2020-11-16
@12q

But how to open the code if it is with tkinter
?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question