The problem is that sometimes 3rd party modules have logging turned on. For example, I run into that when using Selenium for testing.
If you do not want to see any logger output, you can put this at the top of your module:
import logging logging.disable(logging.CRITICAL)
That works fine, until you want to turn on logging for the module you are working on. Here is code that turns off all other loggers. The last line sends a logger message for this module to the console.
import logging for logger_name in logging.Logger.manager.loggerDict.keys(): logging.getLogger(logger_name).setLevel(logging.CRITICAL) logging.debug('hello from my module')