Can't import opensim library in python

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Narek Ginoyan
Posts: 5
Joined: Thu Feb 16, 2023 8:53 pm

Can't import opensim library in python

Post by Narek Ginoyan » Sat Mar 11, 2023 7:17 am

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?

Tags:

User avatar
Mohammadreza Rezaie
Posts: 407
Joined: Fri Nov 24, 2017 12:48 am

Re: Can't import opensim library in python

Post by Mohammadreza Rezaie » Sat Mar 11, 2023 10:00 am

Hi, I had similar issue and downgrading to python 3.9 fixed it.

User avatar
Narek Ginoyan
Posts: 5
Joined: Thu Feb 16, 2023 8:53 pm

Re: Can't import opensim library in python

Post by Narek Ginoyan » Sat Mar 18, 2023 3:08 am

Switching to 3.9 didn't help, but to 3.8 did. Thanks regardless!

POST REPLY