No module named 'omni.appwindow'

when i try to run a python file .py,which is to control the jetbot through keyboard :

from omni.isaac.kit import SimulationApp
import numpy as np
import carb
import omni.appwindow

simulation_app = SimulationApp({"headless": False})

from omni.isaac.jetbot import Jetbot
from omni.isaac.jetbot.controllers import DifferentialController

from omni.isaac.core import World

my_world = World(stage_units_in_meters=0.01)

my_jetbot = my_world.scene.add(
    Jetbot(
        prim_path="/World/Jetbot",
        name="my_jetbot",
        position=np.array([0, 0.0, 2.0])
    ) 
) 

my_controller = DifferentialController(name="simple_control")

my_world.scene.add_default_ground_plane()

command_ = [0.0, 0.0]
def sub_keyboard_event(event, *args, **kwargs):
    """Handle keyboard events
    w,s,a,d as arrow keys for jetbot movement

    Args:
        event (int): keyboard event type
    """
    global command_
    if(
        event.type == carb.input.KeyboardEventType.KEY_PRESS
        or event.type == carb.input.KeyboardEventType.KEY_REPEAT
    ):
        if event.input == carb.input.KeyboardInput.W:
            command_ = [20, 0.0]
        if event.input == carb.input.KeyboardInput.S:
            command_ = [-20, 0.0]
        if event.input == carb.input.KeyboardInput.A:
            command_ = [0.0, np.pi / 5]
        if event.input == carb.input.KeyboardInput.D:
            command_ = [0.0, -np.pi / 5]
    if(event.type == carb.input.KeyboardEventType.KEY_RELEASE):
        command_ = [0.0, 0.0]

    return True

appwindow_ = omni.appwindow.get_default_app_window()
input_ = carb.input.acquire_input_interface()
keyboard_ = appwindow_.get_keyboard()
sub_keyboard_ = input_.subscribe_to_keyboard_events(keyboard_,sub_keyboard_event)

my_world.reset()

while simulation_app.is_running():
    my_world.step(render=True)
    if my_world.is_playing():
        my_jetbot.apply_wheel_actions(my_controller.forward(command=command_))

simulation_app.close()

when i run ‘~/.local/share/ov/pkg/isaac_sim-2022.2.1/python.sh’ keyboard_control.py in terminal,it shows the error like 'No module named ‘omni.appwindow’ ,what is the matter? HELP!!!

Hi @gaozhao22 - The error message “No module named ‘omni.appwindow’” indicates that Python cannot find the ‘omni.appwindow’ module. This could be due to several reasons:

  1. The ‘omni.appwindow’ module is not installed: Make sure that the module is installed. If it’s part of a larger package, make sure that the package is installed.
  2. The ‘omni.appwindow’ module is not in your Python path: Python uses the PYTHONPATH environment variable to determine where to look for modules. If the ‘omni.appwindow’ module is installed in a location that’s not in your PYTHONPATH, Python won’t be able to find it.
  3. You’re using the wrong version of Python: The ‘omni.appwindow’ module might only be compatible with a specific version of Python. Make sure that you’re using the correct version.
  4. The ‘omni.appwindow’ module is not compatible with your operating system: Some Python modules are only compatible with certain operating systems. If you’re trying to use the ‘omni.appwindow’ module on an unsupported operating system, you might get this error.

If none of these solutions work, then please reach out to us.

I have the same problem and tried several imports.
from omni.isaac.kit import SimulationApp works for me.
But any other import fails.

I tried using the python.sh file as described here:
https://docs.omniverse.nvidia.com/isaacsim/latest/install_python.html

and the “run single python file” configuration of VSCode as described here:
https://docs.omniverse.nvidia.com/isaacsim/latest/manual_standalone_python.html#visual-studio-code-vscode-support

The following is my code:

import time
import omni
import omni.isaac.core as oc
from omni.isaac.kit import SimulationApp

kit = SimulationApp({'headless': False})
time.sleep(5)
kit.close()

When i remove line 3 it works.
However most other modules seem to fail.

I checked the launch.json and checked the python paths in the setup_python_env I then modified the path in the setup_python_env to make sure it pointed to $PYTHONPATH:$SCRIPT_DIR/exts/ which from my understanding means it should have all extensions in this folder in its path.

I am not sure how I should install these separately, if you could provide a bit more context here. I only found information on how to install standard python packages via pip into omniverse code. But these are Omniverse packages.

As i am using the provided vscode / python.sh file which from my understanding sets the python interpreter. Not sure if I understand this functionality correctly though.

OS: Ubuntu 20.04

I had a close look at the HelloWorld.py example:

from omni.isaac.kit import SimulationApp
simulation_app = SimulationApp({"headless": False}) # we can also run as headless.
from omni.isaac.core import World
from omni.isaac.core.objects import DynamicCuboid
import numpy as np

Basically what you have to do is to import the relevant packages, after the simulation has been started,
then the context is set and everything is available and works as intended.

2 Likes