Install a New Python Package from PyPI

You can use the omni.kit.pipapi extension to install external Python packages that you would like to use within Kit or any Omniverse app. This snippet is useful if you just want to install a Python package for yourself or for scripting purposes. omni.kit.pipapi.install wraps pip install calls and reroutes package installation into a user specified environment folder which is added to sys.path.

If you are creating an extension that depends on a Python package, then you should use the extension config to include the Python package requirement so that it is installed when the extension is enabled.

Warning

omni.kit.pipapi.install() is a blocking call and slow. It is meant to be used for debugging and development. For final product packages, it should be installed at build-time and packaged inside extensions.

# omni.kit.pipapi extension is required
import omni.kit.pipapi

omni.kit.pipapi.install(
    package="semver",
    version="2.13.0",
    module="semver", # sometimes module is different from package name, module is used for import check
    ignore_import_check=False,
    ignore_cache=False,
    use_online_index=True,
    surpress_output=False,
    extra_args=[]
)

# use the newly installed package
import semver
ver = semver.VersionInfo.parse('1.2.3-pre.2+build.4')
print(ver)