Score:0

Sublime text 4 does not run Python

pk flag

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?

Score:1
in flag

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.

Pinguto avatar
pk flag
Am I wrong, or is there already a print in the opening question? and the Python - Syntax Check seems set up as you described .. ideas?
OdatNurd avatar
in flag
There is, which is why it says that your issue isn't the first one, but the second one. To be clear, you want to ***not*** use `Python - Syntax Check` because all that does is compile your code but nothing else.
Pinguto avatar
pk flag
I understand. I accept the answer, even though I solved it by switching to Visual Studio Code.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.