ENH: add render warn for None
diff --git a/gym/envs/box2d/bipedal_walker.py b/gym/envs/box2d/bipedal_walker.py
index 392d3277d27..bea56f4c7f7 100644
--- a/gym/envs/box2d/bipedal_walker.py
+++ b/gym/envs/box2d/bipedal_walker.py
@@ -606,6 +606,14 @@ def step(self, action: np.ndarray):
         return np.array(state, dtype=np.float32), reward, terminated, False, {}
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         try:
             import pygame
             from pygame import gfxdraw
diff --git a/gym/envs/box2d/car_racing.py b/gym/envs/box2d/car_racing.py
index adddb25e5ef..bee7f3acd2f 100644
--- a/gym/envs/box2d/car_racing.py
+++ b/gym/envs/box2d/car_racing.py
@@ -565,7 +565,14 @@ def step(self, action: Union[np.ndarray, int]):
         return self.state, step_reward, terminated, truncated, {}
 
     def render(self):
-        return self._render(self.render_mode)
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+        else:
+            return self._render(self.render_mode)
 
     def _render(self, mode: str):
         assert mode in self.metadata["render_modes"]
diff --git a/gym/envs/box2d/lunar_lander.py b/gym/envs/box2d/lunar_lander.py
index 87185c43a70..fb8e8e0f934 100644
--- a/gym/envs/box2d/lunar_lander.py
+++ b/gym/envs/box2d/lunar_lander.py
@@ -600,6 +600,14 @@ def step(self, action):
         return np.array(state, dtype=np.float32), reward, terminated, False, {}
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         try:
             import pygame
             from pygame import gfxdraw
diff --git a/gym/envs/classic_control/acrobot.py b/gym/envs/classic_control/acrobot.py
index d618078a0ff..4ca31ca138f 100644
--- a/gym/envs/classic_control/acrobot.py
+++ b/gym/envs/classic_control/acrobot.py
@@ -4,7 +4,7 @@
 import numpy as np
 from numpy import cos, pi, sin
 
-from gym import core, spaces
+from gym import core, logger, spaces
 from gym.error import DependencyNotInstalled
 
 __copyright__ = "Copyright 2013, RLPy http://acl.mit.edu/RLPy"
@@ -277,6 +277,14 @@ def _dsdt(self, s_augmented):
         return dtheta1, dtheta2, ddtheta1, ddtheta2, 0.0
 
     def render(self):
+        if self.render_mode is None:
+            logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         try:
             import pygame
             from pygame import gfxdraw
diff --git a/gym/envs/classic_control/cartpole.py b/gym/envs/classic_control/cartpole.py
index a1d4045993b..39005d7f877 100644
--- a/gym/envs/classic_control/cartpole.py
+++ b/gym/envs/classic_control/cartpole.py
@@ -207,6 +207,14 @@ def reset(
         return np.array(self.state, dtype=np.float32), {}
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         try:
             import pygame
             from pygame import gfxdraw
diff --git a/gym/envs/classic_control/continuous_mountain_car.py b/gym/envs/classic_control/continuous_mountain_car.py
index 3d427b6708d..0995b6232ae 100644
--- a/gym/envs/classic_control/continuous_mountain_car.py
+++ b/gym/envs/classic_control/continuous_mountain_car.py
@@ -189,6 +189,14 @@ def _height(self, xs):
         return np.sin(3 * xs) * 0.45 + 0.55
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         try:
             import pygame
             from pygame import gfxdraw
diff --git a/gym/envs/classic_control/mountain_car.py b/gym/envs/classic_control/mountain_car.py
index f25aeab914b..1bae60fe497 100644
--- a/gym/envs/classic_control/mountain_car.py
+++ b/gym/envs/classic_control/mountain_car.py
@@ -167,6 +167,14 @@ def _height(self, xs):
         return np.sin(3 * xs) * 0.45 + 0.55
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         try:
             import pygame
             from pygame import gfxdraw
diff --git a/gym/envs/classic_control/pendulum.py b/gym/envs/classic_control/pendulum.py
index 3a1c6edac34..536d57e909d 100644
--- a/gym/envs/classic_control/pendulum.py
+++ b/gym/envs/classic_control/pendulum.py
@@ -163,6 +163,14 @@ def _get_obs(self):
         return np.array([np.cos(theta), np.sin(theta), thetadot], dtype=np.float32)
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         try:
             import pygame
             from pygame import gfxdraw
diff --git a/gym/envs/mujoco/mujoco_env.py b/gym/envs/mujoco/mujoco_env.py
index 44ddbd72d86..62e01c3a37b 100644
--- a/gym/envs/mujoco/mujoco_env.py
+++ b/gym/envs/mujoco/mujoco_env.py
@@ -228,6 +228,14 @@ def _step_mujoco_simulation(self, ctrl, n_frames):
             self.sim.step()
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         width, height = self.width, self.height
         camera_name, camera_id = self.camera_name, self.camera_id
         if self.render_mode in {"rgb_array", "depth_array"}:
@@ -348,6 +356,14 @@ def _step_mujoco_simulation(self, ctrl, n_frames):
         mujoco.mj_rnePostConstraint(self.model, self.data)
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         if self.render_mode in {
             "rgb_array",
             "depth_array",
diff --git a/gym/envs/toy_text/blackjack.py b/gym/envs/toy_text/blackjack.py
index 8a767e08ec0..4bcce17a086 100644
--- a/gym/envs/toy_text/blackjack.py
+++ b/gym/envs/toy_text/blackjack.py
@@ -190,6 +190,14 @@ def reset(
         return self._get_obs(), {}
 
     def render(self):
+        if self.render_mode is None:
+            gym.logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+            return
+
         try:
             import pygame
         except ImportError:
diff --git a/gym/envs/toy_text/cliffwalking.py b/gym/envs/toy_text/cliffwalking.py
index 9b543174e29..cc3ed523668 100644
--- a/gym/envs/toy_text/cliffwalking.py
+++ b/gym/envs/toy_text/cliffwalking.py
@@ -5,7 +5,7 @@
 
 import numpy as np
 
-from gym import Env, spaces
+from gym import Env, logger, spaces
 from gym.envs.toy_text.utils import categorical_sample
 from gym.error import DependencyNotInstalled
 
@@ -163,7 +163,13 @@ def reset(self, *, seed: Optional[int] = None, options: Optional[dict] = None):
         return int(self.s), {"prob": 1}
 
     def render(self):
-        if self.render_mode == "ansi":
+        if self.render_mode is None:
+            logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+        elif self.render_mode == "ansi":
             return self._render_text()
         else:
             return self._render_gui(self.render_mode)
diff --git a/gym/envs/toy_text/frozen_lake.py b/gym/envs/toy_text/frozen_lake.py
index 404d2b08af3..65ea6429771 100644
--- a/gym/envs/toy_text/frozen_lake.py
+++ b/gym/envs/toy_text/frozen_lake.py
@@ -5,7 +5,7 @@
 
 import numpy as np
 
-from gym import Env, spaces, utils
+from gym import Env, logger, spaces, utils
 from gym.envs.toy_text.utils import categorical_sample
 from gym.error import DependencyNotInstalled
 
@@ -267,7 +267,13 @@ def reset(
         return int(self.s), {"prob": 1}
 
     def render(self):
-        if self.render_mode == "ansi":
+        if self.render_mode is None:
+            logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
+        elif self.render_mode == "ansi":
             return self._render_text()
         else:  # self.render_mode in {"human", "rgb_array"}:
             return self._render_gui(self.render_mode)
diff --git a/gym/envs/toy_text/taxi.py b/gym/envs/toy_text/taxi.py
index d9b9a817017..ac5ef188174 100644
--- a/gym/envs/toy_text/taxi.py
+++ b/gym/envs/toy_text/taxi.py
@@ -5,7 +5,7 @@
 
 import numpy as np
 
-from gym import Env, spaces, utils
+from gym import Env, logger, spaces, utils
 from gym.envs.toy_text.utils import categorical_sample
 from gym.error import DependencyNotInstalled
 
@@ -278,6 +278,12 @@ def reset(
         return int(self.s), {"prob": 1.0, "action_mask": self.action_mask(self.s)}
 
     def render(self):
+        if self.render_mode is None:
+            logger.warn(
+                "You are calling render method without specifying any render mode. "
+                "You can specify the render_mode at initialization, "
+                f'e.g. gym("{self.spec.id}", render_mode="rgb_array")'
+            )
         if self.render_mode == "ansi":
             return self._render_text()
         else:  # self.render_mode in {"human", "rgb_array"}:

Add a warning when `render` is called without specifying `render_mode`, see https://github.com/openai/gym/issues/3108