python -u: Unbuffered Output for CI Logs
Stop Python buffering its logs so CI shows output live.
python -u forces stdout and stderr to be unbuffered. In CI, this makes log lines appear immediately instead of arriving in a burst at the end (or being lost on a crash).
What it does
Disables buffering on the standard streams so writes flush right away. Without it, output to a non-TTY (a CI log) is block-buffered and can appear delayed or out of order.
Common usage
Terminal
python -u script.py
# Equivalent via environment variable:
PYTHONUNBUFFERED=1 python script.pyCommon CI symptom: missing logs on crash
When a job is killed (timeout, OOM) before buffered output flushes, the last log lines never appear, hiding the real cause. Run with -u or set PYTHONUNBUFFERED=1 so logs are not lost.
Terminal
# Make CI logs reliable:
export PYTHONUNBUFFERED=1
python long_running.pyRelated guides
python -c: Run a One-Liner in CIHow python -c runs a snippet of Python directly from the command line, common CI uses like version and import…
python -m pytest: Run Tests with the Project on sys.pathWhy python -m pytest beats a bare pytest in CI, how it adds the current directory to sys.path, and the import…