Sublime text 4 does not run Python

I would like to try to learn Python, but Sublime text 4, as I try to run any test script by pressing CTRL + B gives me confirmation that it has been executed, but no output.

import sys
print(sys.platform)

The result:

[Finished in 19ms]

Any ideas what I'm doing wrong? is it a configuration error? If so, which one?


Presuming that you're using the built in Python build system that ships with Sublime Text, the most common reasons for executing Python code and not seeing any output (and also not seeing any errors) are:

  1. Your Python code doesn't actually generate any output, such as a script that is just 2 + 2 without a print() wrapping it. This often happens when people are used to using a REPL environment or are following a tutorial where a REPL is used.

  2. When you carry out your first Python build, you'll be asked if you want to use the Python build or the Python - Syntax Check build; thereafter Sublime remembers your choice and keeps using it. The Syntax Check variant sounds like a good idea because who doesn't want extra checking for their code? However, all it does is compile your code but not actually run it, in which case you will only ever see output if your code is broken.

Your issue isn't the first one (but if it was, remember that for any output to appear outside of a REPL, print() what you want to see, so my guess would be that it's the second one. If that's the case, use Tools > Build With... from the menu while editing a Python file and try picking the Python build to see if that works any better.