Skip to content

Simbody Visualizer does not work with Python Wheels #4247

@alexbeattie42

Description

@alexbeattie42

I have built and installed the new Python wheels for OpenSim and they are working well so far. Thanks for the great work on this!

I have noticed that the RPATH for the Simbody visualizer is not properly set on Linux. This only surfaces with a clean path. Otherwise the Simbody visualizer will be picked up from a system OpenSim install if that is on path. Attempting to use the visualizer with a clean path produces this error:

simbody-visualizer: error while loading shared libraries: libSimTKsimbody.so.3.9: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "/home/alexbeat/AlexDev/osim-rl/examples/basic.py", line 3, in <module>
    env = L2M2019Env(visualize=True)
  File "/home/alexbeat/AlexDev/osim-rl/osim/env/osim.py", line 473, in __init__
    super(L2M2019Env, self).__init__(visualize=visualize, integrator_accuracy=integrator_accuracy)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alexbeat/AlexDev/osim-rl/osim/env/osim.py", line 299, in __init__
    self.load_model()
    ~~~~~~~~~~~~~~~^^
  File "/home/alexbeat/AlexDev/osim-rl/osim/env/osim.py", line 559, in load_model
    super(L2M2019Env, self).load_model(model_path)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/alexbeat/AlexDev/osim-rl/osim/env/osim.py", line 305, in load_model
    self.osim_model = OsimModel(self.model_path, self.visualize, integrator_accuracy = self.integrator_accuracy)
                      ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alexbeat/AlexDev/osim-rl/osim/env/osim.py", line 77, in __init__
    self.model_state = self.model.initSystem()
                       ~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/alexbeat/AlexDev/osim-rl/.venv/lib/python3.14/site-packages/opensim/simulation.py", line 26152, in initSystem
    return _simulation.Model_initSystem(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
RuntimeError: std::exception in 'SimTK::State & OpenSim::Model::initSystem()': std::exception

The LD_LIBRARY_PATH can be temporarily overridden within the virtual environment with this jankiness to get it to work:

export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$VIRTUAL_ENV/lib/$(python -c 'import sys;print(f"python{sys.version_info.major}.{sys.version_info.minor}")')/site-packages/opensim:$LD_LIBRARY_PATH

I hope that there is a better way though and that the invocation of the visualizer could figure out that the library is contained inside the wheel.

Related: #4245

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions