Page 1 of 1

Can't import opensim library in python

Posted: Sat Mar 11, 2023 7:17 am
by no_mouth_stud
Hello. I want to run a CMC Simulation using a python script. I am using Windows with Python 3.10.9(no conda) and OpenSim 4.4. I followed the instructions as in https://simtk-confluence.stanford.edu:8 ... +in+Python

I try to run this code

Code: Select all

import opensim as osim

model = osim.Model("model.osim")
cmcTool = osim.CMCTool("CMC_Setup.xml")
cmcTool.setModel(model)
cmcTool.run()

I get this error

Code: Select all

Traceback (most recent call last):
  File "script_directory\CMC_Run.py", line 1, in <module>
    import opensim as osim
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\opensim\__init__.py", line 9, in <module>
    from .simbody import *
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\opensim\simbody.py", line 13, in <module>
    from . import _simbody
ImportError: DLL load failed while importing _simbody: The specified module could not be found.
What may be the problem?

Re: Can't import opensim library in python

Posted: Sat Mar 11, 2023 10:00 am
by kernalnet
Hi, I had similar issue and downgrading to python 3.9 fixed it.

Re: Can't import opensim library in python

Posted: Sat Mar 18, 2023 3:08 am
by no_mouth_stud
Switching to 3.9 didn't help, but to 3.8 did. Thanks regardless!