I am trying to create an extension that can connect to a Microsoft Azure Instance and load resources into OmniVerse. I’m having some trouble importing the azure.identity library on module load. It’s pretty easy to reproduce this.
Steps to reproduce:
1.; Install Azure Python libraries:
pip install azure-mgmt-resource
pip install azure-identity
- add these libraries to the extension.toml:
...
[python.pipapi]
requirements = [
"azure-identity",
"azure-mgmt-resource"
]
use_online_index = true
...
then in a python script (test.py) enter:
# Import the needed credential and management objects from the libraries.
from azure.identity import AzureCliCredential
from azure.mgmt.resource import ResourceManagementClient
import os
# Acquire a credential object using CLI-based authentication.
credential = AzureCliCredential()
# Retrieve subscription ID from environment variable.
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
# Obtain the management object for resources.
resource_client = ResourceManagementClient(credential, subscription_id)
# Retrieve the list of resource groups
group_list = resource_client.resource_groups.list()
# Show the groups in formatted output
column_width = 40
print("Resource Group".ljust(column_width) + "Location")
print("-" * (column_width * 2))
for group in list(group_list):
print(f"{group.name:<{column_width}}{group.location}")
The script runs correctly if I run “python.exe test”
You don’t even need to execute it, to demonstrate the extension load failure.
The extension fails to load with:
2022-06-29 06:46:49 [Info] [omni.ext.plugin] [ext: omni.hello.test-1.0.0] registered (path: c:/users/.../kit-exts-project/exts/omni.hello.test)
2022-06-29 06:46:49 [Info] [omni.ext.plugin] [ext: omni.hello.test-1.0.0] deps:
2022-06-29 06:46:49 [Info] [omni.ext.impl._internal] Adding c:\users\...\kit-exts-project\exts\omni.hello.test to sys.path
2022-06-29 06:46:49 [Info] [omni.ext.plugin] About to startup: [ext: omni.hello.test-1.0.0] (order: 0) Triggered by API/CLI/Config. (path: c:/users/.../kit-exts-project/exts/omni.hello.test)
2022-06-29 06:46:49 [Error] [omni.ext.impl.custom_importer] Failed to import python module omni.hello.test. Error: No module named 'azure.identity'. Traceback:
2022-06-29 06:46:49 [Error] [omni.ext.impl.custom_importer] File "c:\users\...\kit-exts-project\exts\omni.hello.test\omni\hello\test\__init__.py", line 1, in <module>
2022-06-29 06:46:49 [Error] [omni.ext.impl.custom_importer] File "c:\users\...\kit-exts-project\exts\omni.hello.test\omni\hello\test\extension.py", line 5, in <module>
2022-06-29 06:46:49 [Error] [omni.ext.impl.custom_importer] from azure.identity import DefaultAzureCredential
2022-06-29 06:46:49 [Error] [omni.ext.impl.custom_importer] ModuleNotFoundError: No module named 'azure.identity'
2022-06-29 06:46:49 [Error] [carb.scripting-python.plugin] Exception: Extension python module: 'omni.hello.test' in 'c:\users\...\kit-exts-project\exts\omni.hello.test' failed to load.
If you comment out this line, the extension loads fine.
from azure.identity import DefaultAzureCredential
So, something in the extension load can’t find the azure-identity package.?
I don’t think this is library specific as it runs fine in python. So, it seems it’s something with packaging these dependencies into the embedded kit python library. The package is clearly installed in my local python library, but probably not getting added to the embedded python.