Python (lint) Advice With Omni Imports

Hi all,

To catch “compile time” errors in python one has to rely on some kind of lint process. I’m using Visual Studio Code, but the lint extension doesn’t pick up any of the omni.ui, omni.kit, omni.usd, pxr, carb imports and so on.

So my question is, how do you get these working?

It drives me mad only hitting syntax and type errors at runtime rather than at “compile” (ie lint) time - i’m a c++ developer you see, so used to that sort of development “help”, and developing python with this runtime error catching is driving me mad!

Any help and/or advice would bve greatly appreciated please :)

  • Simon.

Hi Simon,

We have an improvement in the works, which enables autocompletion/intellisense for binary python modules like omni.ui. We do that by generating .pyi (python stub) files. That improves python coding experience.

We also in general looking into ways to improve python developing, specifically on vscode with pylance.

Having python module automatically reloaded we heavily rely on that as substitute for c++ compile-time checks. When developing an extension we just constantly hit “save” button and see UI changes immediately and errors in console.

Hi Anovoselov,

Thanks for the update, that sounds really useful when it comes on line.
I love the auto-update when saving by the way, it’s brilliant and a game changer when developing with Python!

  • Simon.
1 Like

Please include stub files in the upcoming release. Would massively improve development speed given the current state of the documentation. If there is an easy way to generate them myself please share. I was able to get a decent number of the packages processed but not without some tinkering.

Hi @Josh.n, I’ve reached out to the dev team about stub file generation. Thanks for your request!

Yes, it’s annoying not to have completion and linting.

For what it’s worth, here’s my hacky solution:

  • set VSCode to kit’s python
  • In your VSCode workspace settings.json, have it point to .env file for environment variables.
  • copy the contents of <kit_root>/ to that file, only the environment variables. You need to change $VARIABLE to ${VARIABLE} for VSCode (easy replace all).
  • now I have completion and linting

Perhaps there’s a better way but it works for now.
Hope it helps

@bart.sekura Thanks for the suggestion. For reference, this is what worked for me

Windows with the 2021.3 release my setup_python_env.bat only contains

@echo off

so I created the file ./create-2021.3.0/kit/vars.env which contains


And then in VSCode set the python .env path accordingly and enabled linting with pylint

The new release also has included .pyi stubs so thanks to the Omniverse team for the quick response!

with the latest version you also get full Pylance support that give you a lot of extra information on the methods and autocompletion provided you start type annotating your code

Let us know how this work for you we continue to invest to make it a great Dev experience

@Josh.n Thanks for tip on how to set it up on Windows. The difference seems Linux needs paths specified explicitly, but on Windows it refers to site folder.

After setting it up on Windows, bizarrely, linting does not work for me. I can debug a single file and it works, which means it does resolve import paths, but linting does not and I get squiggles and no completion. VSCode seems really flaky, it works for you which means it’s the extension problem on my environment. Oh well.

Is this already released or will be?
Are you referring to manual steps we talked about above or something else?

It may help to add the kit python executable to your system PATH and the site folder to your PYTHONPATH. VSCode didn’t seem to want to listen to the specified interpreter before I did that.

I also am not able to get linting/completion with the Pixar libraries beyond the top level module imports. I saw there were some comments about this in scripts/ but whatever fix was applied doesn’t seem to be working. Any suggestions @dfagnou ?

Starting with Create 2021.3.0 we included .pyi file as well as an example of creating VSCode project.
Go to Window → Extension Manager, on the top left there is “Plus” button. It creates project template with one extension in it. If you open it with VSCode you should have Pylance enabled and autocompletion working. It may suggest to install you certain VSCode extensions when opening.

We used to rely on setting PATH env before and then switched in favor of .pyi files. As getting it to work properly was extremely hard and overall it is limited by scraping abilities IDE used.

Latest Create also contains new documentation page “Embedded Python” with a bit of extra useful information around Python configuration.

1 Like

@anovoselov Thank you! I tried it and it works pretty well.