A Python script can finish successfully without printing anything. Unlike the interactive prompt, a script does not automatically display the value of every expression.

Try a small script

Save this as hello.py:

def greet():
    return "Hello from Python"

print(greet())

Run python3 hello.py on macOS/Linux, or use your installed Python launcher on Windows. The expected output is Hello from Python. Defining greet() alone produces no output; the final line calls it and prints its return value.

Identify what the terminal is doing

  • You see >>>: you started the interactive interpreter. Enter Python code there, or exit interactive mode before entering shell commands.
  • The shell prompt returns: check whether your script prints anything and whether you ran the intended file.
  • The cursor waits: look for input(), a loop, or a network request waiting for completion. Ctrl+C interrupts ordinary Python execution.
  • Output appears late: try python3 -u hello.py when output is being buffered, or print("progress", flush=True).

Check the interpreter and file

python3 -c "import sys; print(sys.executable); print(sys.version)"

If Python cannot locate the script or an input file, follow the file path checks. Running python3 hello.py does not require adding executable permission to the script.

Sources and verification

The greeting example is included in the local Python verification run; operating-system launcher names may differ.