I'm using Git Bash to run my Python scripts on Windows. I noticed that the console doesn't print while my scripts are running. All the strings are printed just when the scripts finish. I read that is a buffer and line break issue. How can I fix it?
I am using MINGW64 on Windows10, and python -u works for me. For example,
python -u foo.py
From python --help:
-u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x see man page for details on internal buffering relating to '-u'
I solve this including sys.stdout.flush() after each print().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With