From b099f4d8b30c38ac1b442260f4ae15d75d97f657 Mon Sep 17 00:00:00 2001 From: Omar Younis Date: Thu, 27 Jun 2024 10:54:05 +0200 Subject: [PATCH] fix pygame --- gymnasium/__init__.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/gymnasium/__init__.py b/gymnasium/__init__.py index d7d280a08..a4c281ef7 100644 --- a/gymnasium/__init__.py +++ b/gymnasium/__init__.py @@ -21,6 +21,19 @@ register_envs, ) +# Initializing pygame initializes audio connections through SDL. SDL uses alsa by default on all Linux systems +# SDL connecting to alsa frequently create these giant lists of warnings every time you import an environment using +# pygame +# DSP is far more benign (and should probably be the default in SDL anyways) + +import os +import sys + +if sys.platform.startswith("linux"): + os.environ["SDL_AUDIODRIVER"] = "dsp" + +os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide" + # necessary for `envs.__init__` which registers all gymnasium environments and loads plugins from gymnasium import envs from gymnasium import spaces, utils, vector, wrappers, error, logger, functional @@ -55,20 +68,6 @@ ] __version__ = "1.0.0a2" - -# Initializing pygame initializes audio connections through SDL. SDL uses alsa by default on all Linux systems -# SDL connecting to alsa frequently create these giant lists of warnings every time you import an environment using -# pygame -# DSP is far more benign (and should probably be the default in SDL anyways) - -import os -import sys - -if sys.platform.startswith("linux"): - os.environ["SDL_AUDIODRIVER"] = "dsp" - -os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide" - try: from farama_notifications import notifications