isaac-sim/IsaacGymEnvs

ImportError when using IsaacGymEnvs with IsaacGym

Akihisa-Watanabe opened this issue · 0 comments

I've encountered an import error when using IsaacGymEnvs alongside IsaacGym. The error message I receive is:

Traceback (most recent call last):
  File "/home/akihisawatanabe/Eureka/eureka/../isaacgymenvs/isaacgymenvs/train.py", line 39, in <module>
    from isaacgymenvs.tasks import isaacgym_task_map
  File "/home/akihisawatanabe/Eureka/isaacgymenvs/isaacgymenvs/tasks/__init__.py", line 29, in <module>
    from .ant import Ant
  File "/home/akihisawatanabe/Eureka/isaacgymenvs/isaacgymenvs/tasks/ant.py", line 33, in <module>
    from isaacgym import gymtorch
  File "/home/akihisawatanabe/Eureka/isaacgym/python/isaacgym/gymtorch.py", line 12, in <module>
    from . import gymapi
  File "/home/akihisawatanabe/Eureka/isaacgym/python/isaacgym/gymapi.py", line 21, in <module>
    from . import gymdeps
  File "/home/akihisawatanabe/Eureka/isaacgym/python/isaacgym/gymdeps.py", line 63, in <module>
    _import_deps()
  File "/home/akihisawatanabe/Eureka/isaacgym/python/isaacgym/gymdeps.py", line 21, in _import_deps
    raise ImportError("PyTorch was imported before isaacgym modules.  Please import torch after isaacgym modules.")
ImportError: PyTorch was imported before isaacgym modules.  Please import torch after isaacgym modules.

Upon inspecting the code, I noticed that in some files like isaacgymenvs/tasks/anymal_terrain.py, the imports are ordered correctly, but in files like isaacgymenvs/tasks/ant.py, the order seems to be causing the error:

import numpy as np
import os
import torch

from isaacgym import gymtorch
from isaacgym import gymapi
from isaacgym.gymtorch import *

Perhaps importing torch after the isaacgym modules might resolve the error. Would it be acceptable if I to submit a pull request to adjust the import order?