PIP Installation: Issue with import order

Hi,

Again, thank you so much for working on the pip installation even though it’s an experimental feature!

I can now launch the SimulationApp successfully! But I run into problems when I try to work with my custom RL project. So far we used this class from omni.isaac.gym.vec_env import VecEnvBase to open the SimulationApp. However, the problem is that I cannot import from omni.isaac.gym.
Can this be fixed, or will I have to restructure my project, such that I can open the app first?

Python 3.10.14 (main, May  6 2024, 19:42:50) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import isaacsim
>>> import omni.isaac
>>> import omni.isaac.kit
>>> import omni.isaac.gym
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'omni.isaac.gym'
>>> import omni.isaac.core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'omni.isaac.core'

Same problem for me, I guess you need to set SimulationApp and then try to import omni.isaac.core.

Hi @johannes.pitz

As @liziteng0430 indicated, all the Isaac Sim/Omniverse import statements need to be placed after instantiating the SimulationApp class.

https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#running-in-interactive-interpreter-notebooks

Thanks for the answer!
But is are you planning to fix that in the future? Importing isaacsim already allows importing omni.isaac.kit. Therefore I would assume it is also possible to similarly allow importing omni.isaac.gym and others.
Also this is already possible when installing via the omniverse launcher.

Hi @johannes.pitz

Please, note that this behavior is not a bug (but the way Omniverse works) so there in no need to “fix” it.

From SimulationApp:
Omniverse loads various plugins at runtime which cannot be imported unless the Toolkit is already running. Thus, it is necessary to launch the Toolkit first from your python application and then import everything else.

Hm, I understand that it works like that for many omniverse packages, but that is also the case when I install isaacsim via the omniverse launcher. However, the difference is that when I install it via the launcher some imports work (before launching the app). For example omni.isaac.kit and omni.isaac.gym.
With the import isaacsim statement you fixed the problem that one needs to import omni.isaac.kit to launch the app at all. Now another previously supported way to launch the app was by creating a VecEnvBase form omni.isaac.gym.vec_env. And I would really appreciate if you would consider to allow this workflow also for the pip installation.
(Otherwise I would have write a custom VecEnvBase class to which I can pass an already launched app.)

1 Like

This can easily be fixed by adding

        os.path.join(isaacsim_path, "exts", "omni.isaac.gym"),

    paths += [
        os.path.join(isaacsim_path, "exts", "omni.isaac.kit"),
        os.path.join(isaacsim_path, "exts", "omni.isaac.gym"),
    ]

in line 67 in the isaacsim.__init__.py

Could you please consider adding that to the official package?