Pylance can not resolve my external dependencies installed via pipapi

I added the yaml package in my extension.toml

[python.pipapi]
requirements=["yaml"]
use_online_index = true

it is working. In VS Code Plyance can not resolve this depencency.

tl;dr
Thank you for your hints on how to to inculde external dependencies installed via pipapi also for Pylance.

Hi @MartinBischoff. For any external dependencies, you need to add the paths to the .vscode/settings.json manually.

Packages are installed by default in a location like this:
C:\Users\bob\AppData\Local\ov\data\Kit\Code\2022.2\pip3-envs\default

Thank you for this hint @mati-nvidia. As I was using Create I found my package at C:\Users\martin\AppData\Local\ov\data\Kit\Create.Next\2022.3\pip3-envs\default\yaml. Adding this path to settings.json didn’t resolve my issue.

When copying the the yaml package into the workspaceFolder of my extension and adding {workspaceFolder}/yaml Pylance finds the package. But this is no practical solution.

I then found this pylance issue here.
The yaml package comes with a .pydwhich seems like it can not be interpreted by pylance.

I could switch to other yaml packages as pyyaml but didn’t succeed installing any alternative via pipapi.

I’m surprised that didn’t work. It’s effectively the same as putting it in the workspace. Did you try using the “Reload Window” command in VSCode to trigger reindexing?

#1 here show’s how to reload: visual studio code - How to restart VScode after editing extension's config? - Stack Overflow

Yes. I was restarting VS code before and tried again with reloading the window this time. I see VS code searching and fining all dependencies except my manually installed one.

Still looking into it. I’m having trouble getting yaml to install on Create-2022.3 in order to verify. I’m using omni.kit.pipapi.install, but it should work the same. You didn’t do anything special?

In regards to .pyd, if there are any .py or .pyi files, it should find those and intellisense should be available for those.

i didn’t do anything special. In python console the following works for me:

import omni.kit.pipapi
omni.kit.pipapi.install('yaml')

import yaml

in extension.toml I can do

[python.pipapi]
requirements=["yaml"]
use_online_index = true

I have problems installing pyyaml however.

Thanks @MartinBischoff. I’m still having trouble installing. I’ve logged this issue: OM-73658, so that I can have a dev dig into it.

Ok. So, PyYAML did work for you and idk what the yaml package is. :) What happens with pipapi.install() is that it does an import check to see if the package has been installed and to verify that the install worked. When the import name is different from the PyPI name, it will throw an error unless you use the module kwarg:


Once the install worked for me, I set added the path to the .vscode/settings.json:

NOTE: One windows you need to use forward slashes or escape the backslashed

I ran the Reload Window command and now intellisense works for me.

Here is what I found out:

  1. The PyYAML package is included in Omniverse Create and “yaml” module which is included in this package is already available. pipapi is not needed.
    terminal

  2. My actual issue that Pylance could not resolve “yaml” in my scripts I resolved by simply running pip install pyyaml in the python terminal in code.

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