From 5af90e379d069e4cba7c8db44d4135466f209183 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Mon, 9 Jan 2023 21:14:45 +0800 Subject: [PATCH] Update prompt messages for extra dependencies (#250) --- .pre-commit-config.yaml | 2 +- docs/environments/classic_control.md | 2 +- gymnasium/envs/box2d/bipedal_walker.py | 2 +- gymnasium/envs/box2d/car_dynamics.py | 2 +- gymnasium/envs/box2d/car_racing.py | 2 +- gymnasium/envs/box2d/lunar_lander.py | 2 +- gymnasium/envs/classic_control/acrobot.py | 2 +- gymnasium/envs/classic_control/cartpole.py | 2 +- gymnasium/envs/classic_control/continuous_mountain_car.py | 2 +- gymnasium/envs/classic_control/mountain_car.py | 2 +- gymnasium/envs/classic_control/pendulum.py | 2 +- gymnasium/envs/mujoco/mujoco_env.py | 7 +++++-- gymnasium/envs/mujoco/mujoco_rendering.py | 2 +- gymnasium/envs/phys2d/cartpole.py | 6 +++--- gymnasium/envs/phys2d/pendulum.py | 6 +++--- gymnasium/envs/toy_text/blackjack.py | 2 +- gymnasium/envs/toy_text/cliffwalking.py | 2 +- gymnasium/envs/toy_text/frozen_lake.py | 2 +- gymnasium/envs/toy_text/taxi.py | 2 +- gymnasium/experimental/wrappers/jax_to_numpy.py | 2 +- gymnasium/experimental/wrappers/jax_to_torch.py | 4 ++-- gymnasium/experimental/wrappers/lambda_observations.py | 2 +- gymnasium/experimental/wrappers/numpy_to_torch.py | 2 +- gymnasium/utils/play.py | 4 ++-- gymnasium/utils/save_video.py | 2 +- gymnasium/wrappers/monitoring/video_recorder.py | 4 ++-- gymnasium/wrappers/resize_observation.py | 2 +- pyproject.toml | 2 +- 28 files changed, 39 insertions(+), 36 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3c113707a..0f147e2b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: hooks: - id: codespell args: - - --ignore-words-list=nd,reacher,thist,ths,ure,referenc,wile + - --ignore-words-list=reacher,ure,referenc,wile - repo: https://github.com/PyCQA/flake8 rev: 5.0.4 hooks: diff --git a/docs/environments/classic_control.md b/docs/environments/classic_control.md index fb005959c..9e8c58a3b 100644 --- a/docs/environments/classic_control.md +++ b/docs/environments/classic_control.md @@ -22,7 +22,7 @@ classic_control/pendulum The unique dependencies for this set of environments can be installed via: ````bash -pip install gymnasium[classic_control] +pip install gymnasium[classic-control] ```` There are five classic control environments: Acrobot, CartPole, Mountain Car, Continuous Mountain Car, and Pendulum. All of these environments are stochastic in terms of their initial state, within a given range. In addition, Acrobot has noise applied to the taken action. Also, regarding both mountain car environments, the cars are underpowered to climb the mountain, so it takes some effort to reach the top. diff --git a/gymnasium/envs/box2d/bipedal_walker.py b/gymnasium/envs/box2d/bipedal_walker.py index 7ebc7d120..eaa274cd4 100644 --- a/gymnasium/envs/box2d/bipedal_walker.py +++ b/gymnasium/envs/box2d/bipedal_walker.py @@ -23,7 +23,7 @@ try: ) except ImportError as e: raise DependencyNotInstalled( - "box2D is not installed, run `pip install gymnasium[box2d]`" + "Box2D is not installed, run `pip install gymnasium[box2d]`" ) from e diff --git a/gymnasium/envs/box2d/car_dynamics.py b/gymnasium/envs/box2d/car_dynamics.py index 5a18e7c6a..d46e23806 100644 --- a/gymnasium/envs/box2d/car_dynamics.py +++ b/gymnasium/envs/box2d/car_dynamics.py @@ -19,7 +19,7 @@ try: from Box2D.b2 import fixtureDef, polygonShape, revoluteJointDef except ImportError as e: raise DependencyNotInstalled( - "box2D is not installed, run `pip install gymnasium[box2d]`" + "Box2D is not installed, run `pip install gymnasium[box2d]`" ) from e diff --git a/gymnasium/envs/box2d/car_racing.py b/gymnasium/envs/box2d/car_racing.py index 4a9950447..5044bb400 100644 --- a/gymnasium/envs/box2d/car_racing.py +++ b/gymnasium/envs/box2d/car_racing.py @@ -17,7 +17,7 @@ try: from Box2D.b2 import contactListener, fixtureDef, polygonShape except ImportError as e: raise DependencyNotInstalled( - "box2D is not installed, run `pip install gymnasium[box2d]`" + "Box2D is not installed, run `pip install gymnasium[box2d]`" ) from e try: diff --git a/gymnasium/envs/box2d/lunar_lander.py b/gymnasium/envs/box2d/lunar_lander.py index 13094c7f1..49be51df1 100644 --- a/gymnasium/envs/box2d/lunar_lander.py +++ b/gymnasium/envs/box2d/lunar_lander.py @@ -25,7 +25,7 @@ try: ) except ImportError as e: raise DependencyNotInstalled( - "box2d is not installed, run `pip install gymnasium[box2d]`" + "Box2D is not installed, run `pip install gymnasium[box2d]`" ) from e diff --git a/gymnasium/envs/classic_control/acrobot.py b/gymnasium/envs/classic_control/acrobot.py index f807f6748..c1fdc7071 100644 --- a/gymnasium/envs/classic_control/acrobot.py +++ b/gymnasium/envs/classic_control/acrobot.py @@ -296,7 +296,7 @@ class AcrobotEnv(Env): from pygame import gfxdraw except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e if self.screen is None: diff --git a/gymnasium/envs/classic_control/cartpole.py b/gymnasium/envs/classic_control/cartpole.py index 939de53eb..b744fa674 100644 --- a/gymnasium/envs/classic_control/cartpole.py +++ b/gymnasium/envs/classic_control/cartpole.py @@ -221,7 +221,7 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]): from pygame import gfxdraw except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e if self.screen is None: diff --git a/gymnasium/envs/classic_control/continuous_mountain_car.py b/gymnasium/envs/classic_control/continuous_mountain_car.py index 6908c7b31..1158f1843 100644 --- a/gymnasium/envs/classic_control/continuous_mountain_car.py +++ b/gymnasium/envs/classic_control/continuous_mountain_car.py @@ -207,7 +207,7 @@ class Continuous_MountainCarEnv(gym.Env): from pygame import gfxdraw except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e if self.screen is None: diff --git a/gymnasium/envs/classic_control/mountain_car.py b/gymnasium/envs/classic_control/mountain_car.py index 213a2c047..a7de427ac 100644 --- a/gymnasium/envs/classic_control/mountain_car.py +++ b/gymnasium/envs/classic_control/mountain_car.py @@ -182,7 +182,7 @@ class MountainCarEnv(gym.Env): from pygame import gfxdraw except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e if self.screen is None: diff --git a/gymnasium/envs/classic_control/pendulum.py b/gymnasium/envs/classic_control/pendulum.py index 01147587a..f58781330 100644 --- a/gymnasium/envs/classic_control/pendulum.py +++ b/gymnasium/envs/classic_control/pendulum.py @@ -182,7 +182,7 @@ class PendulumEnv(gym.Env): from pygame import gfxdraw except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e if self.screen is None: diff --git a/gymnasium/envs/mujoco/mujoco_env.py b/gymnasium/envs/mujoco/mujoco_env.py index 2a3882157..2b62e8869 100644 --- a/gymnasium/envs/mujoco/mujoco_env.py +++ b/gymnasium/envs/mujoco/mujoco_env.py @@ -177,7 +177,9 @@ class MuJocoPyEnv(BaseMujocoEnv): ): if MUJOCO_PY_IMPORT_ERROR is not None: raise error.DependencyNotInstalled( - f"{MUJOCO_PY_IMPORT_ERROR}. (HINT: you need to install mujoco_py, and also perform the setup instructions here: https://github.com/openai/mujoco-py/.)" + f"{MUJOCO_PY_IMPORT_ERROR}. " + "(HINT: you need to install mujoco-py, and also perform the setup instructions " + "here: https://github.com/openai/mujoco-py.)" ) logger.warn( @@ -324,7 +326,8 @@ class MujocoEnv(BaseMujocoEnv): ): if MUJOCO_IMPORT_ERROR is not None: raise error.DependencyNotInstalled( - f"{MUJOCO_IMPORT_ERROR}. (HINT: you need to install mujoco)" + f"{MUJOCO_IMPORT_ERROR}. " + "(HINT: you need to install mujoco, run `pip install gymnasium[mujoco]`.)" ) super().__init__( diff --git a/gymnasium/envs/mujoco/mujoco_rendering.py b/gymnasium/envs/mujoco/mujoco_rendering.py index b0709edee..41632e183 100644 --- a/gymnasium/envs/mujoco/mujoco_rendering.py +++ b/gymnasium/envs/mujoco/mujoco_rendering.py @@ -687,7 +687,7 @@ class MujocoRenderer: self.viewer = OffScreenViewer(self.model, self.data) else: raise AttributeError( - f"Unexpected mode: {render_mode}, expected modes: human, rgb_arrray, or depth_array" + f"Unexpected mode: {render_mode}, expected modes: human, rgb_array, or depth_array" ) # Add default camera parameters self._set_cam_config() diff --git a/gymnasium/envs/phys2d/cartpole.py b/gymnasium/envs/phys2d/cartpole.py index dfe4d3a70..94cea9663 100644 --- a/gymnasium/envs/phys2d/cartpole.py +++ b/gymnasium/envs/phys2d/cartpole.py @@ -144,7 +144,7 @@ class CartPoleFunctional( from pygame import gfxdraw except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e screen, clock = render_state @@ -216,7 +216,7 @@ class CartPoleFunctional( import pygame except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e pygame.init() @@ -231,7 +231,7 @@ class CartPoleFunctional( import pygame except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e pygame.display.quit() pygame.quit() diff --git a/gymnasium/envs/phys2d/pendulum.py b/gymnasium/envs/phys2d/pendulum.py index 9a1f1f8db..3fbb203d0 100644 --- a/gymnasium/envs/phys2d/pendulum.py +++ b/gymnasium/envs/phys2d/pendulum.py @@ -96,7 +96,7 @@ class PendulumFunctional( from pygame import gfxdraw except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e screen, clock, last_u = render_state @@ -168,7 +168,7 @@ class PendulumFunctional( import pygame except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e pygame.init() @@ -183,7 +183,7 @@ class PendulumFunctional( import pygame except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e pygame.display.quit() pygame.quit() diff --git a/gymnasium/envs/toy_text/blackjack.py b/gymnasium/envs/toy_text/blackjack.py index e911c8637..0ade543b9 100644 --- a/gymnasium/envs/toy_text/blackjack.py +++ b/gymnasium/envs/toy_text/blackjack.py @@ -237,7 +237,7 @@ class BlackjackEnv(gym.Env): import pygame except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[toy_text]`" + "pygame is not installed, run `pip install gymnasium[toy-text]`" ) from e player_sum, dealer_card_value, usable_ace = self._get_obs() diff --git a/gymnasium/envs/toy_text/cliffwalking.py b/gymnasium/envs/toy_text/cliffwalking.py index 7b3c855b4..4b17fa375 100644 --- a/gymnasium/envs/toy_text/cliffwalking.py +++ b/gymnasium/envs/toy_text/cliffwalking.py @@ -210,7 +210,7 @@ class CliffWalkingEnv(Env): import pygame except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[toy_text]`" + "pygame is not installed, run `pip install gymnasium[toy-text]`" ) from e if self.window_surface is None: pygame.init() diff --git a/gymnasium/envs/toy_text/frozen_lake.py b/gymnasium/envs/toy_text/frozen_lake.py index fdebe72b9..f0b48e60f 100644 --- a/gymnasium/envs/toy_text/frozen_lake.py +++ b/gymnasium/envs/toy_text/frozen_lake.py @@ -342,7 +342,7 @@ class FrozenLakeEnv(Env): import pygame except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[toy_text]`" + "pygame is not installed, run `pip install gymnasium[toy-text]`" ) from e if self.window_surface is None: diff --git a/gymnasium/envs/toy_text/taxi.py b/gymnasium/envs/toy_text/taxi.py index 8cf9cb663..1cf4f151d 100644 --- a/gymnasium/envs/toy_text/taxi.py +++ b/gymnasium/envs/toy_text/taxi.py @@ -327,7 +327,7 @@ class TaxiEnv(Env): import pygame # dependency to pygame only if rendering with human except ImportError as e: raise DependencyNotInstalled( - "pygame is not installed, run `pip install gymnasium[toy_text]`" + "pygame is not installed, run `pip install gymnasium[toy-text]`" ) from e if self.window is None: diff --git a/gymnasium/experimental/wrappers/jax_to_numpy.py b/gymnasium/experimental/wrappers/jax_to_numpy.py index fbcbd0ebf..9f4c264a6 100644 --- a/gymnasium/experimental/wrappers/jax_to_numpy.py +++ b/gymnasium/experimental/wrappers/jax_to_numpy.py @@ -110,7 +110,7 @@ class JaxToNumpyV0(Wrapper): """ if jnp is None: raise DependencyNotInstalled( - "Jax is not installed, run `pip install gymnasium[jax]`" + "jax is not installed, run `pip install gymnasium[jax]`" ) super().__init__(env) diff --git a/gymnasium/experimental/wrappers/jax_to_torch.py b/gymnasium/experimental/wrappers/jax_to_torch.py index 961549a3b..2211c8cde 100644 --- a/gymnasium/experimental/wrappers/jax_to_torch.py +++ b/gymnasium/experimental/wrappers/jax_to_torch.py @@ -149,11 +149,11 @@ class JaxToTorchV0(Wrapper): """ if torch is None: raise DependencyNotInstalled( - "Torch is not installed, run `pip install torch`" + "torch is not installed, run `pip install torch`" ) elif jnp is None: raise DependencyNotInstalled( - "Jax is not installed, run `pip install gymnasium[jax]`" + "jax is not installed, run `pip install gymnasium[jax]`" ) super().__init__(env) diff --git a/gymnasium/experimental/wrappers/lambda_observations.py b/gymnasium/experimental/wrappers/lambda_observations.py index 4c8060b9d..9dab2a59e 100644 --- a/gymnasium/experimental/wrappers/lambda_observations.py +++ b/gymnasium/experimental/wrappers/lambda_observations.py @@ -279,7 +279,7 @@ class ResizeObservationV0(LambdaObservationV0): import cv2 except ImportError as e: raise DependencyNotInstalled( - "opencv is not installed, run `pip install gymnasium[other]`" + "opencv (cv2) is not installed, run `pip install gymnasium[other]`" ) from e self.shape: Final[tuple[int, ...]] = tuple(shape) diff --git a/gymnasium/experimental/wrappers/numpy_to_torch.py b/gymnasium/experimental/wrappers/numpy_to_torch.py index f123455d2..41151bc53 100644 --- a/gymnasium/experimental/wrappers/numpy_to_torch.py +++ b/gymnasium/experimental/wrappers/numpy_to_torch.py @@ -112,7 +112,7 @@ class NumpyToTorchV0(Wrapper): """ if torch is None: raise DependencyNotInstalled( - "Torch is not installed, run `pip install torch`" + "torch is not installed, run `pip install torch`" ) super().__init__(env) diff --git a/gymnasium/utils/play.py b/gymnasium/utils/play.py index 1645482e6..1ea4d69d9 100644 --- a/gymnasium/utils/play.py +++ b/gymnasium/utils/play.py @@ -17,7 +17,7 @@ try: from pygame.event import Event except ImportError as e: raise gym.error.DependencyNotInstalled( - "Pygame is not installed, run `pip install gymnasium[classic_control]`" + "pygame is not installed, run `pip install gymnasium[classic-control]`" ) from e try: @@ -26,7 +26,7 @@ try: matplotlib.use("TkAgg") import matplotlib.pyplot as plt except ImportError: - logger.warn("Matplotlib is not installed, run `pip install gymnasium[other]`") + logger.warn("matplotlib is not installed, run `pip install gymnasium[other]`") matplotlib, plt = None, None diff --git a/gymnasium/utils/save_video.py b/gymnasium/utils/save_video.py index a421d20b2..6a2a04f76 100644 --- a/gymnasium/utils/save_video.py +++ b/gymnasium/utils/save_video.py @@ -10,7 +10,7 @@ try: from moviepy.video.io.ImageSequenceClip import ImageSequenceClip except ImportError as e: raise gym.error.DependencyNotInstalled( - "MoviePy is not installed, run `pip install moviepy`" + "moviepy is not installed, run `pip install moviepy`" ) from e diff --git a/gymnasium/wrappers/monitoring/video_recorder.py b/gymnasium/wrappers/monitoring/video_recorder.py index 5a98475a8..732e1f49f 100644 --- a/gymnasium/wrappers/monitoring/video_recorder.py +++ b/gymnasium/wrappers/monitoring/video_recorder.py @@ -45,7 +45,7 @@ class VideoRecorder: import moviepy # noqa: F401 except ImportError as e: raise error.DependencyNotInstalled( - "MoviePy is not installed, run `pip install moviepy`" + "moviepy is not installed, run `pip install moviepy`" ) from e self._async = env.metadata.get("semantics.async") @@ -153,7 +153,7 @@ class VideoRecorder: from moviepy.video.io.ImageSequenceClip import ImageSequenceClip except ImportError as e: raise error.DependencyNotInstalled( - "MoviePy is not installed, run `pip install moviepy`" + "moviepy is not installed, run `pip install moviepy`" ) from e clip = ImageSequenceClip(self.recorded_frames, fps=self.frames_per_sec) diff --git a/gymnasium/wrappers/resize_observation.py b/gymnasium/wrappers/resize_observation.py index a5e9bc4ba..034a2a337 100644 --- a/gymnasium/wrappers/resize_observation.py +++ b/gymnasium/wrappers/resize_observation.py @@ -61,7 +61,7 @@ class ResizeObservation(gym.ObservationWrapper): import cv2 except ImportError as e: raise DependencyNotInstalled( - "opencv is not installed, run `pip install gymnasium[other]`" + "opencv (cv2) is not installed, run `pip install gymnasium[other]`" ) from e observation = cv2.resize( diff --git a/pyproject.toml b/pyproject.toml index 36b53450c..2426924ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ box2d = ["box2d-py ==2.3.5", "pygame ==2.1.3.dev8", "swig ==4.*"] classic-control = ["pygame ==2.1.3.dev8"] classic_control = ["pygame ==2.1.3.dev8"] # kept for backward compatibility mujoco-py = ["mujoco-py >=2.1,<2.2"] -mujoco_py = ["mujoco-py >=2.1,<2.2"] # kept for backward compatibility +mujoco_py = ["mujoco-py >=2.1,<2.2"] # kept for backward compatibility mujoco = ["mujoco >=2.3.1.post1", "imageio >=2.14.1"] toy-text = ["pygame ==2.1.3.dev8"] toy_text = ["pygame ==2.1.3.dev8"] # kept for backward compatibility