Skip to content

Commit 8df6e8e

Browse files
committed
fix mujoco py import
1 parent 2ed3cd3 commit 8df6e8e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

robomimic/envs/env_robosuite.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77
import numpy as np
88
from copy import deepcopy
99

10-
import mujoco_py
1110
import robosuite
1211

1312
import robomimic.utils.obs_utils as ObsUtils
1413
import robomimic.envs.env_base as EB
1514

15+
# protect against missing mujoco-py module, since robosuite might be using mujoco-py or DM backend
16+
try:
17+
import mujoco_py
18+
MUJOCO_EXCEPTIONS = [mujoco_py.builder.MujocoException]
19+
except ImportError:
20+
MUJOCO_EXCEPTIONS = []
21+
1622

1723
class EnvRobosuite(EB.EnvBase):
1824
"""Wrapper class for robosuite environments (https://github.com/ARISE-Initiative/robosuite)"""
@@ -375,7 +381,7 @@ def rollout_exceptions(self):
375381
that the entire training run doesn't crash because of a bad policy that causes unstable
376382
simulation computations.
377383
"""
378-
return (mujoco_py.builder.MujocoException)
384+
return tuple(MUJOCO_EXCEPTIONS)
379385

380386
def __repr__(self):
381387
"""

0 commit comments

Comments
 (0)