Update prompt messages for extra dependencies (#250)

This commit is contained in:
Xuehai Pan
2023-01-09 21:14:45 +08:00
committed by GitHub
parent 1dfdf45480
commit 5af90e379d
28 changed files with 39 additions and 36 deletions

View File

@@ -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:

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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__(

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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:

View File

@@ -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:

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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(

View File

@@ -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