From b2030a249cd0ce9484eb7713921f609c7a47d2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Somoza?= Date: Tue, 28 May 2024 17:19:01 -0400 Subject: [PATCH] Fix object has no attribute 'flush' when using without a console (#8271) fix --- src/diffusers/utils/logging.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/diffusers/utils/logging.py b/src/diffusers/utils/logging.py index 2e80d30f13..6f93450c41 100644 --- a/src/diffusers/utils/logging.py +++ b/src/diffusers/utils/logging.py @@ -82,7 +82,9 @@ def _configure_library_root_logger() -> None: # This library has already configured the library root logger. return _default_handler = logging.StreamHandler() # Set sys.stderr as stream. - _default_handler.flush = sys.stderr.flush + + if sys.stderr: # only if sys.stderr exists, e.g. when not using pythonw in windows + _default_handler.flush = sys.stderr.flush # Apply our default configuration to the library root logger. library_root_logger = _get_library_root_logger()