Skip to content

Commit 8fb4c70

Browse files
Import error update
1 parent 573bca8 commit 8fb4c70

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

robosuite/devices/keyboard.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"""
44

55
import numpy as np
6-
from pynput.keyboard import Controller, Key, Listener
6+
try:
7+
from pynput.keyboard import Controller, Key, Listener
8+
except ImportError as e:
9+
print(f"Error: {e}.")
710

811
from robosuite.devices import Device
912
from robosuite.utils.transform_utils import rotation_matrix

robosuite/devices/spacemouse.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@
2121
from collections import namedtuple
2222

2323
import numpy as np
24-
from pynput.keyboard import Controller, Key, Listener
24+
try:
25+
from pynput.keyboard import Controller, Key, Listener
26+
except ImportError as exc:
27+
print(f"Unable to load module pynput, required to interface with SpaceMouse. Error: {exc}")
2528

2629
from robosuite.utils.log_utils import ROBOSUITE_DEFAULT_LOGGER
2730

2831
try:
2932
import hid
3033
except ModuleNotFoundError as exc:
31-
raise ImportError(
34+
print(
3235
"Unable to load module hid, required to interface with SpaceMouse. "
3336
"Only macOS is officially supported. Install the additional "
3437
"requirements with `pip install -r requirements-extra.txt`"
35-
) from exc
36-
37-
from pynput.keyboard import Controller, Key, Listener
38+
)
3839

3940
import robosuite.macros as macros
4041
from robosuite.devices import Device
@@ -371,9 +372,9 @@ def _postprocess_device_outputs(self, dpos, drotation):
371372
return dpos, drotation
372373

373374

374-
if __name__ == "__main__":
375+
# if __name__ == "__main__":
375376

376-
space_mouse = SpaceMouse()
377-
for i in range(100):
378-
print(space_mouse.control, space_mouse.control_gripper)
379-
time.sleep(0.02)
377+
# space_mouse = SpaceMouse()
378+
# for i in range(100):
379+
# print(space_mouse.control, space_mouse.control_gripper)
380+
# time.sleep(0.02)

0 commit comments

Comments
 (0)