Cannot use requests py module in my extension for CREATE

I created a simple extension and loaded it in CREATE 2023.3.3-rc.15 (with the help of link_app.bat and startup.bat).
I want to use requests py module in the extension.
For this I modified extension.toml and added lines:

[python.pipapi]
requirements = ['requests']

Also, I added ‘import requests’ to the extension .py file and after saving it I saw a message in console:

2023-06-29 16:53:21 [377,223ms] [Error] [omni.ext._impl.custom_importer] Failed to import python module omni.hello.world. Error: No module named 'requests'. Traceback:
Traceback (most recent call last):
  File "d:/omni/kit-extension-template-main/app/kit/kernel/py\omni\ext\_impl\custom_importer.py", line 76, in import_module
    return importlib.import_module(name)
  File "d:\omni\kit-extension-template-main\app\kit\python\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "d:\omni\kit-extension-template-main\exts\omni.hello.world\omni\hello\world\__init__.py", line 1, in <module>
    from .extension import *
  File "d:\omni\kit-extension-template-main\exts\omni.hello.world\omni\hello\world\extension.py", line 6, in <module>
    from .http_client import HttpClient
  File "d:\omni\kit-extension-template-main\exts\omni.hello.world\omni\hello\world\http_client.py", line 10, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

2023-06-29 16:53:21 [377,234ms] [Error] [carb.scripting-python.plugin] Exception: Extension python module: 'omni.hello.world' in 'd:\omni\kit-extension-template-main\exts\omni.hello.world' failed to load.

At:
  d:/omni/kit-extension-template-main/app/kit/kernel/py\omni\ext\_impl\_internal.py(189): startup
  d:/omni/kit-extension-template-main/app/kit/kernel/py\omni\ext\_impl\_internal.py(285): startup_extension
  PythonExtension.cpp::startup()(2): <module>

2023-06-29 16:53:21 [377,235ms] [Error] [omni.ext.plugin] [ext: omni.hello.world-1.0.0] Failed to startup python extension.

I have also installed requests py module with the command ‘pip install requests’.
Please advise on how to resolve this.
Thank you.

I found an answer. CREATE uses it’s own python which is located at ‘app\kit\python\python.exe’.
‘app’ is a folder link created in your extension’s folder after running link_app.bat.
So, I started terminal at folder ‘app\kit\python’ and there are files like:

.packman.sha1
PACKAGE-DEPS.yaml
PACKAGE-INFO.yaml
python.exe
python3.dll
python37.dll
pythonw.exe
vcruntime140.dll
venvlauncher.exe
venvwlauncher.exe

I run a command
python.exe -m pip install requests
and this allowed me to get requests module into CREATE’s python.
After that all works as expected.

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