Why is there a message 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"
How can I disable this message?
You can always initialize individual modules manually, but pygame. init() initialize all imported pygame modules is a convenient way to get everything started. The init() functions for individual modules will raise exceptions when they fail.
Open a terminal, and type 'sudo apt-get install idle pygame', enter your password and type 'y' at the prompts, if necessary. 2. After the installation completes, enter 'python' in the terminal to launch Python. Verify that it's using version 2.7 or newer, then at the Python prompt enter 'import pygame'.
It works for me:
import os os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" import pygame
I didn't see a natural way to do it (yours is the only Google result for this that I could find), but I did achieve the same thing by temporarily disabling stdout while importing pygame.
import os, sys with open(os.devnull, 'w') as f: # disable stdout oldstdout = sys.stdout sys.stdout = f import pygame # enable stdout sys.stdout = oldstdout
Here's the alternative suggested by @Mad Physicist:
import contextlib with contextlib.redirect_stdout(None): import pygame
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