Sublime Forum

Can't run my code, am I being dim?

#1

Hey, brand new user to Sublime here!
I code python and am learning HTML, I previously used IDLE for coding my school preojects and decided to move to Sublime for versatility, it’s great and I love it. Unfortunately, I have no idea how to run my code.
IDLE had a built-in runtime environment where you just hit F5 and the code did its thing. I’m guessing Sublime doesn’t have that?
I’ve made a little test program, no code except the actual program. After a quick google I saw people taking about the build tool. I am aware of it, but people just saying ‘it’s there’ doesn’t get me any closer to running this code.

‘python’ is not recognized as an internal or external command,
operable program or batch file.
[Finished in 0.1s]

I am new, confused and would appreciate any and all help, treat me like I’m a five year old :slight_smile:

0 Likes

#2

You’re correct in that Sublime doesn’t support any sort of IDLE or REPL type environment directly. A build system is essentially just a way to tell Sublime “When I press this key, I want you to run this external program for me”.

For the case of Python, as you can see there is a build system that ships with Sublime already set up for that. However it wants to run the python command in order to run your program, but you don’t have Python installed on your system; or you do but it’s not on the PATH and so Sublime doesn’t know how to find it.

If you install Python and ensure that it’s on the PATH, then the command that you used above will run your program for you. For this to work, you need to be able to open a standard windows command prompt and enter python as a command and have it run the Python interpreter; if it tells you the same error as above, then Sublime can’t run it either.

Something else to note (because this comes up often) is that the build system will execute the program you give it and show you the output that it generates as it happens, but you can’t interact with the running program. For example if you had the sort of program that asks you for your name or a number and then does something with it, your program will appear to hang forever because it’s waiting for you to enter input but there is no way to do so.

The SublimeREPL package implements a method to run python programs interactively, which may help here (though I’ve never used it myself). Additionally the Terminus package implements a command prompt directly inside of Sublime, where you could run your program interactively.

0 Likes