Skip to content

3 Ways to disable output buffer when running Python

Question briefing

When using output redirection to run a Python script or placing the Python script into Docker, the output may not be immediately visible on the screen.

python > out.log nohup &

sudo docker run my-python-app


  1. use python -u
  2. set environment variable, PYTHONUNBUFFERED=1
  3. print('Hello World!', flush=True) in Python > 3.3