Update requirement list and add quotes around pip install for macos users (#1001)

This commit is contained in:
Mark Towers
2024-04-06 15:44:09 +01:00
committed by GitHub
parent 0fe94efa26
commit 2869279232
29 changed files with 55 additions and 62 deletions

View File

@@ -449,7 +449,7 @@ register(
# --- For shimmy compatibility # --- For shimmy compatibility
def _raise_shimmy_error(*args: Any, **kwargs: Any): def _raise_shimmy_error(*args: Any, **kwargs: Any):
raise ImportError( raise ImportError(
"To use the gym compatibility environments, run `pip install shimmy[gym-v21]` or `pip install shimmy[gym-v26]`" 'To use the gym compatibility environments, run `pip install "shimmy[gym-v21]"` or `pip install "shimmy[gym-v26]"`'
) )

View File

@@ -23,7 +23,7 @@ try:
) )
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"Box2D is not installed, run `pip install gymnasium[box2d]`" 'Box2D is not installed, run `pip install "gymnasium[box2d]"`'
) from e ) from e
@@ -628,7 +628,7 @@ class BipedalWalker(gym.Env, EzPickle):
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[box2d]`" 'pygame is not installed, run `pip install "gymnasium[box2d]"`'
) from e ) from e
if self.screen is None and self.render_mode == "human": if self.screen is None and self.render_mode == "human":

View File

@@ -19,7 +19,7 @@ try:
from Box2D.b2 import fixtureDef, polygonShape, revoluteJointDef from Box2D.b2 import fixtureDef, polygonShape, revoluteJointDef
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"Box2D is not installed, run `pip install gymnasium[box2d]`" 'Box2D is not installed, run `pip install "gymnasium[box2d]"`'
) from e ) from e

View File

@@ -17,7 +17,7 @@ try:
from Box2D.b2 import contactListener, fixtureDef, polygonShape from Box2D.b2 import contactListener, fixtureDef, polygonShape
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"Box2D is not installed, run `pip install gymnasium[box2d]`" 'Box2D is not installed, run `pip install "gymnasium[box2d]"`'
) from e ) from e
try: try:
@@ -27,7 +27,7 @@ try:
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[box2d]`" 'pygame is not installed, run `pip install "gymnasium[box2d]"`'
) from e ) from e

View File

@@ -24,7 +24,7 @@ try:
) )
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"Box2D is not installed, run `pip install gymnasium[box2d]`" 'Box2D is not installed, run `pip install "gymnasium[box2d]"`'
) from e ) from e
@@ -683,7 +683,7 @@ class LunarLander(gym.Env, EzPickle):
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[box2d]`" 'pygame is not installed, run `pip install "gymnasium[box2d]"`'
) from e ) from e
if self.screen is None and self.render_mode == "human": if self.screen is None and self.render_mode == "human":

View File

@@ -298,7 +298,7 @@ class AcrobotEnv(Env):
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic-control]"`'
) from e ) from e
if self.screen is None: if self.screen is None:

View File

@@ -265,7 +265,7 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic-control]"`'
) from e ) from e
if self.screen is None: if self.screen is None:
@@ -528,7 +528,7 @@ class CartPoleVectorEnv(VectorEnv):
from pygame import gfxdraw from pygame import gfxdraw
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic_control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) )
if self.screens is None: if self.screens is None:

View File

@@ -212,7 +212,7 @@ class Continuous_MountainCarEnv(gym.Env):
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
if self.screen is None: if self.screen is None:

View File

@@ -187,7 +187,7 @@ class MountainCarEnv(gym.Env):
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
if self.screen is None: if self.screen is None:

View File

@@ -187,7 +187,7 @@ class PendulumEnv(gym.Env):
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
if self.screen is None: if self.screen is None:

View File

@@ -13,8 +13,7 @@ try:
import mujoco import mujoco
except ImportError as e: except ImportError as e:
raise error.DependencyNotInstalled( raise error.DependencyNotInstalled(
"Could not import mujoco" 'MuJoCo is not installed, run `pip install "gymnasium[mujoco]"`'
"(HINT: you need to install mujoco, run `pip install gymnasium[mujoco]`.)"
) from e ) from e

View File

@@ -145,7 +145,7 @@ class CartPoleFunctional(
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
screen, clock = render_state screen, clock = render_state
@@ -217,7 +217,7 @@ class CartPoleFunctional(
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
pygame.init() pygame.init()
@@ -232,7 +232,7 @@ class CartPoleFunctional(
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
pygame.display.quit() pygame.display.quit()
pygame.quit() pygame.quit()

View File

@@ -117,7 +117,7 @@ class PendulumFunctional(
from pygame import gfxdraw from pygame import gfxdraw
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
screen, clock, last_u = render_state screen, clock, last_u = render_state
@@ -191,7 +191,7 @@ class PendulumFunctional(
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
pygame.init() pygame.init()
@@ -210,7 +210,7 @@ class PendulumFunctional(
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic-control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
pygame.display.quit() pygame.display.quit()
pygame.quit() pygame.quit()

View File

@@ -353,7 +353,7 @@ class BlackjackFunctional(
import pygame import pygame
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic_control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) )
rng = seeding.np_random(0)[0] rng = seeding.np_random(0)[0]
@@ -377,7 +377,7 @@ class BlackjackFunctional(
import pygame import pygame
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[toy_text]`" 'pygame is not installed, run `pip install "gymnasium[toy_text]"`'
) )
screen, dealer_top_card_value_str, dealer_top_card_suit = render_state screen, dealer_top_card_value_str, dealer_top_card_suit = render_state
@@ -483,7 +483,7 @@ class BlackjackFunctional(
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic_control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) from e ) from e
pygame.display.quit() pygame.display.quit()
pygame.quit() pygame.quit()

View File

@@ -218,7 +218,7 @@ class CliffWalkingFunctional(
import pygame import pygame
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[classic_control]`" 'pygame is not installed, run `pip install "gymnasium[classic_control]"`'
) )
cell_size = (60, 60) cell_size = (60, 60)
@@ -302,7 +302,7 @@ class CliffWalkingFunctional(
import pygame import pygame
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[toy_text]`" 'pygame is not installed, run `pip install "gymnasium[toy_text]"`'
) )
( (
window_surface, window_surface,
@@ -349,7 +349,7 @@ class CliffWalkingFunctional(
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[toy-text]`" 'pygame is not installed, run `pip install "gymnasium[toy-text]"`'
) from e ) from e
pygame.display.quit() pygame.display.quit()
pygame.quit() pygame.quit()

View File

@@ -238,7 +238,7 @@ class BlackjackEnv(gym.Env):
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[toy-text]`" 'pygame is not installed, run `pip install "gymnasium[toy-text]"`'
) from e ) from e
player_sum, dealer_card_value, usable_ace = self._get_obs() player_sum, dealer_card_value, usable_ace = self._get_obs()

View File

@@ -211,7 +211,7 @@ class CliffWalkingEnv(Env):
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[toy-text]`" 'pygame is not installed, run `pip install "gymnasium[toy-text]"`'
) from e ) from e
if self.window_surface is None: if self.window_surface is None:
pygame.init() pygame.init()

View File

@@ -343,7 +343,7 @@ class FrozenLakeEnv(Env):
import pygame import pygame
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[toy-text]`" 'pygame is not installed, run `pip install "gymnasium[toy-text]"`'
) from e ) from e
if self.window_surface is None: if self.window_surface is None:

View File

@@ -328,7 +328,7 @@ class TaxiEnv(Env):
import pygame # dependency to pygame only if rendering with human import pygame # dependency to pygame only if rendering with human
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[toy-text]`" 'pygame is not installed, run `pip install "gymnasium[toy-text]"`'
) from e ) from e
if self.window is None: if self.window is None:

View File

@@ -18,7 +18,7 @@ try:
from pygame.event import Event from pygame.event import Event
except ImportError as e: except ImportError as e:
raise gym.error.DependencyNotInstalled( 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 ) from e
try: try:
@@ -27,7 +27,7 @@ try:
matplotlib.use("TkAgg") matplotlib.use("TkAgg")
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
except ImportError: 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 matplotlib, plt = None, None
@@ -358,7 +358,7 @@ class PlayPlot:
if plt is None: if plt is None:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"matplotlib is not installed, run `pip install gymnasium[other]`" 'matplotlib is not installed, run `pip install "gymnasium[other]"`'
) )
num_plots = len(self.plot_names) num_plots = len(self.plot_names)
@@ -411,6 +411,6 @@ class PlayPlot:
if plt is None: if plt is None:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"matplotlib is not installed, run `pip install gymnasium[other]`" 'matplotlib is not installed, run `pip install "gymnasium[other]"`'
) )
plt.pause(0.000001) plt.pause(0.000001)

View File

@@ -12,7 +12,7 @@ try:
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
except ImportError as e: except ImportError as e:
raise gym.error.DependencyNotInstalled( raise gym.error.DependencyNotInstalled(
"moviepy is not installed, run `pip install moviepy`" 'moviepy is not installed, run `pip install "gymnasium[other]"`'
) from e ) from e

View File

@@ -90,7 +90,7 @@ class AtariPreprocessing(gym.Wrapper, gym.utils.RecordConstructorArgs):
import cv2 # noqa: F401 import cv2 # noqa: F401
except ImportError: except ImportError:
raise gym.error.DependencyNotInstalled( raise gym.error.DependencyNotInstalled(
"opencv-python package not installed, run `pip install gymnasium[other]` to get dependencies for atari" 'opencv-python package not installed, run `pip install "gymnasium[other]"` to get dependencies for atari'
) )
assert frame_skip > 0 assert frame_skip > 0

View File

@@ -18,7 +18,7 @@ try:
import jax.numpy as jnp import jax.numpy as jnp
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"Jax is not installed therefore cannot call `numpy_to_jax`, run `pip install gymnasium[jax]`" 'Jax is not installed therefore cannot call `numpy_to_jax`, run `pip install "gymnasium[jax]"`'
) )
__all__ = ["JaxToNumpy", "jax_to_numpy", "numpy_to_jax"] __all__ = ["JaxToNumpy", "jax_to_numpy", "numpy_to_jax"]
@@ -145,7 +145,7 @@ class JaxToNumpy(
""" """
if jnp is None: if jnp is None:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"jax is not installed, run `pip install gymnasium[jax]`" 'Jax is not installed, run `pip install "gymnasium[jax]"`'
) )
gym.utils.RecordConstructorArgs.__init__(self) gym.utils.RecordConstructorArgs.__init__(self)
gym.Wrapper.__init__(self, env) gym.Wrapper.__init__(self, env)

View File

@@ -26,7 +26,7 @@ try:
from jax import dlpack as jax_dlpack from jax import dlpack as jax_dlpack
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"Jax is not installed therefore cannot call `torch_to_jax`, run `pip install gymnasium[jax]`" 'Jax is not installed therefore cannot call `torch_to_jax`, run `pip install "gymnasium[jax]"`'
) )
try: try:
@@ -36,7 +36,7 @@ try:
Device = Union[str, torch.device] Device = Union[str, torch.device]
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"Torch is not installed therefore cannot call `torch_to_jax`, run `pip install torch`" 'Torch is not installed therefore cannot call `torch_to_jax`, run `pip install "gymnasium[torch]"`'
) )

View File

@@ -19,7 +19,7 @@ try:
Device = Union[str, torch.device] Device = Union[str, torch.device]
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"Torch is not installed therefore cannot call `torch_to_numpy`, run `pip install torch`" 'Torch is not installed therefore cannot call `torch_to_numpy`, run `pip install "gymnasium[torch]"`'
) )

View File

@@ -302,7 +302,7 @@ class RecordVideo(
import moviepy # noqa: F401 import moviepy # noqa: F401
except ImportError as e: except ImportError as e:
raise error.DependencyNotInstalled( raise error.DependencyNotInstalled(
"MoviePy is not installed, run `pip install moviepy`" 'MoviePy is not installed, run `pip install "gymnasium[other]"`'
) from e ) from e
def _capture_frame(self): def _capture_frame(self):
@@ -397,7 +397,7 @@ class RecordVideo(
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
except ImportError as e: except ImportError as e:
raise error.DependencyNotInstalled( raise error.DependencyNotInstalled(
"MoviePy is not installed, run `pip install moviepy`" 'MoviePy is not installed, run `pip install "gymnasium[other]"`'
) from e ) from e
clip = ImageSequenceClip(self.recorded_frames, fps=self.frames_per_sec) clip = ImageSequenceClip(self.recorded_frames, fps=self.frames_per_sec)
@@ -510,7 +510,7 @@ class HumanRendering(
import pygame import pygame
except ImportError: except ImportError:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"pygame is not installed, run `pip install gymnasium[box2d]`" 'pygame is not installed, run `pip install "gymnasium[box2d]"`'
) )
if self.env.render_mode == "rgb_array_list": if self.env.render_mode == "rgb_array_list":
last_rgb_array = self.env.render() last_rgb_array = self.env.render()

View File

@@ -377,7 +377,7 @@ class ResizeObservation(
import cv2 import cv2
except ImportError as e: except ImportError as e:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"opencv (cv2) is not installed, run `pip install gymnasium[other]`" 'opencv (cv2) is not installed, run `pip install "gymnasium[other]"`'
) from e ) from e
self.shape: Final[tuple[int, int]] = tuple(shape) self.shape: Final[tuple[int, int]] = tuple(shape)

View File

@@ -37,7 +37,7 @@ class JaxToNumpy(VectorWrapper):
""" """
if jnp is None: if jnp is None:
raise DependencyNotInstalled( raise DependencyNotInstalled(
"jax is not installed, run `pip install gymnasium[jax]`" 'Jax is not installed, run `pip install "gymnasium[jax]"`'
) )
super().__init__(env) super().__init__(env)

View File

@@ -34,8 +34,7 @@ dynamic = ["version"]
[project.optional-dependencies] [project.optional-dependencies]
# Update dependencies in `all` if any are added or removed # Update dependencies in `all` if any are added or removed
atari = ["shimmy[atari] >=0.1.0,<1.0"] atari = ["ale_py >= 0.8"]
accept-rom-license = ["autorom[accept-rom-license] ~=0.4.2"]
box2d = ["box2d-py ==2.3.5", "pygame >=2.1.3", "swig ==4.*"] box2d = ["box2d-py ==2.3.5", "pygame >=2.1.3", "swig ==4.*"]
classic-control = ["pygame >=2.1.3"] classic-control = ["pygame >=2.1.3"]
classic_control = ["pygame >=2.1.3"] # kept for backward compatibility classic_control = ["pygame >=2.1.3"] # kept for backward compatibility
@@ -45,13 +44,8 @@ mujoco = ["mujoco >=2.1.5", "imageio >=2.14.1"]
toy-text = ["pygame >=2.1.3"] toy-text = ["pygame >=2.1.3"]
toy_text = ["pygame >=2.1.3"] # kept for backward compatibility toy_text = ["pygame >=2.1.3"] # kept for backward compatibility
jax = ["jax >=0.4.0", "jaxlib >=0.4.0", "flax >= 0.5.0"] jax = ["jax >=0.4.0", "jaxlib >=0.4.0", "flax >= 0.5.0"]
other = [ torch = ["torch >=1.0.0"]
"lz4 >=3.1.0", other = ["moviepy >=1.0.0", "matplotlib >=3.0", "opencv-python >=3.0"]
"opencv-python >=3.0",
"matplotlib >=3.0",
"moviepy >=1.0.0",
"torch >=1.0.0",
]
all = [ all = [
# All dependencies above except accept-rom-license # All dependencies above except accept-rom-license
# NOTE: No need to manually remove the duplicates, setuptools automatically does that. # NOTE: No need to manually remove the duplicates, setuptools automatically does that.
@@ -65,7 +59,7 @@ all = [
"pygame >=2.1.3", "pygame >=2.1.3",
# mujoco-py # mujoco-py
"mujoco-py >=2.1,<2.2", "mujoco-py >=2.1,<2.2",
"cython<3", "cython <3",
# mujoco # mujoco
"mujoco >=2.1.5", "mujoco >=2.1.5",
"imageio >=2.14.1", "imageio >=2.14.1",
@@ -75,17 +69,17 @@ all = [
"jax >=0.4.0", "jax >=0.4.0",
"jaxlib >=0.4.0", "jaxlib >=0.4.0",
"flax >= 0.5.0", "flax >= 0.5.0",
# torch
"torch >=1.0.0",
# other # other
"lz4 >=3.1.0",
"opencv-python >=3.0", "opencv-python >=3.0",
"matplotlib >=3.0", "matplotlib >=3.0",
"moviepy >=1.0.0", "moviepy >=1.0.0",
"torch >=1.0.0",
] ]
testing = [ testing = [
"pytest ==7.1.3", "pytest ==7.1.3",
"scipy >= 1.7.3", "scipy >=1.7.3",
"dill>=0.3.7", "dill >=0.3.7",
] ]
[project.urls] [project.urls]