Sublime Forum

Using Python in Sublime

#1

Hey please tell me how can i use Sublime to type and run Python Programmes.
I saw some tutorials in which they change build system and then Ctrl+B to run but its no working its gives an error -

'python' is not recognized as an internal or external command, operable program or batch file. [Finished in 0.4s with exit code 1] [shell_cmd: python -u "C:\Users\chief\Desktop\sd.py"] [dir: C:\Users\chief\Desktop] [path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\]

Hope you can understand what am trying to say .

0 Likes

#2

Hi @Chief1, Python is not in your PATH
See the instructions here for adding python to your PATH
Python executable should be located in C:\Users\chief\AppData\Local\Programs\Python\Python38 (if you have python 3.8 installed).
Here’s a video about some common build system problems.

2 Likes

#3

So i did what you said now its working but when i run a programme it executes only first line of it.

in my case i programmed a calculator so first it asks for the input then nothing happens
.

0 Likes

#4

sublime build systems are not interactive, to get an interactive build system, you should:

  1. install Terminus
    i. bring up the command palette (ctrl+shift+p)
    ii. run Package Control: Install Package
    iii. search for Terminus and hit enter
  2. open Python/Python.sublime-build
    i. bring up the command palette (ctrl+shift+p)
    ii. run View Package File
    iii. search for Python/Python.sublime-build and hit enter
  3. add these lines
    "target": "terminus_exec",
    "cancel": "terminus_cancel_build",

here’s a video about Terminus.

3 Likes

#5

FWIW, Here’s another way to run builds interactively in sublime without Terminus. This is for Windows (there are videos for mac and linux)

1 Like