Import BaseSample Module not found (omni.isaac.examples)

Hello,

With version 2022.2.1 the import of the BaseSample does not work anymore if I want to run the script via Terminal. If I import it in my extension it does work though. Is there any reason this could happen?

I run my script with this command after opening the Terminal from the omniverse Isaac launcher:

python.bat extension_examples\Offl_Rep\offline_generation.py

After Starting the simulation App it could not import the BaseSample. I will paste the script until the line it fails:

from bezier import Surface
from omni.isaac.kit import SimulationApp
import os
# Set rendering parameters and create an instance of kit
CONFIG = {"renderer": "RayTracedLighting", "headless": False, "width": 1024, "height": 1024, "num_frames": 10}
simulation_app = SimulationApp(launch_config=CONFIG)



import carb
import random
import math
import numpy as np
from pxr import UsdGeom, Usd, Gf, UsdPhysics, PhysxSchema

from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core import World
...

I want to import the BaseSample Class and with version 2022.2.0 it did work quite well. I don’t get an flake8 error in my VisualStudio Code window aswell. But in the Terminal following error is shown:

....
[3.737s] [ext: omni.isaac.cortex-0.3.2] startup
[3.738s] [ext: omni.kit.window.stats-0.1.2] startup
[3.739s] [ext: omni.isaac.sim.python-2022.2.1] startup
[3.740s] Simulation App Starting
[11.397s] app ready
[11.592s] RTX ready
[11.786s] Simulation App Startup Complete
Traceback (most recent call last):
  File "extension_examples\Offl_Rep\offline_generation.py", line 26, in <module>
    from omni.isaac.examples.base_sample import BaseSample
ModuleNotFoundError: No module named 'omni.isaac.examples'

What did change? I can also see that the example module exists in the exts folder of my isaac installation.

Thank you for your help

EDIT:

Seems like the import problems appear for omni.isaac.core and omni.replicator.core aswell if I try to import them after running the python.bat. For omni.isaac.kit there was no problem importing it

Hi @valentinhendrik - Can you try to run this example again after it fails first time?

Let us know if that way it works.

I already tried that, it does not unfortunately

Thanks for the report, I can confirm this, we will get back to you with a solution.

1 Like

Hi there,

the BaseSample class has been created to be used in extension workflows and not as standalone apps. It has therefore not been tested for such scenarios. In the current version, this does not work anymore because not every extension is added by default to the pythonpath. Only enabled extensions are added, where the base sample is not enabled by default.

If you still plan to use it in a standalone example you can manually add "omni.isaac.examples" = {} to /apps/omni.isaac.sim.python.kit

Or enable it in the standalone app:

from omni.isaac.core.utils.extensions import enable_extension
enable_extension("omni.isaac.examples")
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core import World
1 Like

This works, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.