Kit Python Package

Kit is published as a Python (PIP, wheel) package. This means that you can use Kit as a Python library in your Python projects.

It can be found PyPI index. But it is a placeholder package, to install Kit from PyPI you need pass an extra index URL to pip:

pip install omniverse-kit --extra-index-url https://pypi.nvidia.com

Getting Started

python -m venv myenv
myenv\Scripts\activate
pip install omniverse-kit --extra-index-url https://pypi.nvidia.com
python -m omni.kit_app

In this example we create a new virtual environment, activate it, install Kit into it as python package, and run Kit. It will start in the same way as if it was started from the kit.exe, but instead your python is used.

KitApp Example

The omni.kit_app module provides an initial bootstrapping and KitApp class, which is a Pythonic way to start Kit. It is a thin wrapper around the kit.exe command line interface, and it provides a way to start Kit from Python, to pass command line arguments to it, to control the basic update loop:

from omni.kit_app import KitApp

import sys


if __name__ == "__main__":
    # KitApp is a wrapper over the omni.kit.app.IApp interface
    app = KitApp()

    # Startup kit and ask for the omni.ui extension. Kit will start it including all its dependencies
    # Add any extra command line arguments to the startup call, allowing the user to pass more to the script
    app.startup(["--enable", "omni.ui"] + sys.argv[1:])

    import omni.ui as ui

    # Create a simple window with a button and a float field
    my_window = ui.Window("Example Window", width=300, height=300)
    with my_window.frame:
        with ui.VStack():
            f = ui.FloatField()

            def clicked(f=f):
                print("clicked")
                f.model.set_value(f.model.get_value_as_float() + 1)

            ui.Button("Plus One", clicked_fn=clicked)

    # keep the app running until user exits
    while app.is_running():
        app.update()

    # Shutdown the app and get the return code
    sys.exit(app.shutdown())

In this example we startup Kit asking it to enable omni.ui extension. Use it to build a simple UI window. After that we keep app update loop running until app is signaled to exit. That will only work if among enabled extension is omni.kit.loop (or similar) which implements the main update loop interface (omni::kit::IRunLoopRunner). Otherwise Kit will exit.

The from omni.kit_app import KitApp import must be the first of omniverse imports, it sets up the environment (loads Carbonite, adds library and python paths).

Typically extensions subscribe to update loop events (like render UI every frame, process new input events, etc). However, for some applications it might be useful to have a full control over the update loop. To call explicit API of various extensions, rather than rely on their event-based API:

from omni.kit_app import KitApp

import sys


if __name__ == "__main__":
    # KitApp is a wrapper over the omni.kit.app.IApp interface
    app = KitApp()

    # Startup kit and ask for the omni.usd extension. Kit will start it including all its dependencies
    app.startup(["--enable", "omni.usd"])

    # Only now that extension started we can import it
    import omni.usd
    omni.usd.get_context().new_stage()
    stage = omni.usd.get_context().get_stage()
    print(stage)

    # Shutdown the app and get the return code
    sys.exit(app.shutdown())

In this example we startup Kit asking it to enable omni.usd extension. After that extension is available (added to sys.path, startup was called) and we can use it in our Python code.

EULA

On the first import of omni.kit_app module, it will ask you to accept the EULA. This is a one-time operation, if accepted, it will not ask again. An alternative way to accept the EULA is to set the environment variable OMNI_KIT_ACCEPT_EULA to yes.

Editable Mode

You can install Kit python package in editable mode, which means that you can modify the source code and see the changes immediately. This is useful for development and debugging.

Assuming you’ve built Kit from source:

pip install -e [path to kit source]/_build/packages/python/omniverse-kit