pythonpygame

How to disable welcome message when importing pygame


When I import pygame, it prints the version and welcome message. The message reads:

pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html

Why is this printed? How can I disable this message?


Solution

  • As can be seen in the source code, the message is not printed if the environment variable PYGAME_HIDE_SUPPORT_PROMPT is set. So the following code could be used to import pygame without printing the message:

    import os
    os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
    import pygame
    

    Note that the value does not have to be "hide" but can be anything else as well, and the environment variable can also be set in other ways to achieve the same.