Running custom Python script results in Linker error

Hello everybody,

We are trying to build and execute some custom scripts in Isaac Sim. The environment is running on Ubuntu 20.04 in headless mode with --no-window and --allow-root options.
Executing the scripts in the integrated GUI editor works fine, but running them as suggested in the docs via the python.sh file does not. We are getting linker errors such as this one (absolute home path replaced by ~):

Traceback (most recent call last):
  File "~/test.py", line 2, in <module>
    from omni.usd.libs.pxr import Gf, Sdf, UsdPhysics
  File "~/.local/share/ov/pkg/isaac_sim-2021.1.1/kit/extscore/omni.usd/omni/usd/__init__.py", line 1, in <module>
    from ._impl import *
  File "~/.local/share/ov/pkg/isaac_sim-2021.1.1/kit/extscore/omni.usd/omni/usd/_impl/__init__.py", line 1, in <module>
    from .._usd import *
ImportError: ~/.local/share/ov/pkg/isaac_sim-2021.1.1/kit/extscore/omni.usd.libs/bin/libgf.so: undefined symbol: _ZN32pxrInternal_v0_20__pxrReserved__11TfMallocTag10_doTaggingE
There was an error running python

We tried

  • Importing from pxr and omni.usd instead. The error message changes to another function, but persists in the same way.
  • Adding all possible directories to LD_LIBRARY_PATH, such as the ones in kit/extscore/omni.usd.libs/pxr, which contain compiled libraries. Does not resolve the issue.
  • Executing and fidgeting with other scripts like the python.sh in the kit directory. Does not help either, and runs into additional errors.
  • Sourcing the paths in the terminal and executing the regular python3 to run the script. Same issue persists.

Any ideas on what the problem is and why it works in the internal script editor?

Can you provide a script to reproduce the issue?

note that you cannot import modules from omniverse/pxr until an omniverse app has started because that is when all of the pxr usd plugins are loaded
See the note here:
https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/python_environment.html#omnikithelper