MocoCasADiSolver is not available in python

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Ekaterina Stansfield
Posts: 9
Joined: Mon Jul 03, 2017 5:37 am

MocoCasADiSolver is not available in python

Post by Ekaterina Stansfield » Sat Nov 25, 2023 6:14 am

I have just made a new installation of OpenSim 4.4 in Python 3.8 numpy 1.20 environment. On trying to run Moco I get an error:

"std::exception in 'OpenSim::MocoSolution OpenSim::MocoStudy::solve() const': MocoCasADiSolver is not available.
Thrown at MocoCasADiSolver.cpp:448 in solveImpl()"

Comparing GUI installation on the same machine with the OpenSim package inside Python environmen, I cannot help noticing that the latter contains no CasADi dlls unlike the former.

Could you please help to resolve the issue?

Tags:

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

Re: MocoCasADiSolver is not available in python

Post by Mohammadreza Rezaie » Sun Nov 26, 2023 8:55 am

Hi, if you are using Conda environment, OpenSim recommends using the conda package: https://anaconda.org/opensim-org/opensim-moco
https://simtk-confluence.stanford.edu:8 ... +in+Python

You can also try adding these lines at the beginning of your script:

Code: Select all

import os
os.add_dll_directory('<dir/to/bin>')

User avatar
katya stansfield
Posts: 4
Joined: Mon Dec 02, 2019 8:39 pm

Re: MocoCasADiSolver is not available in python

Post by katya stansfield » Tue Dec 05, 2023 4:08 am

Thank you for help: I installed opensim-moco in a python38 miniconda environment** and run "os.add_dll_directory..." (I assume that the path to bin folder is the path inside the environment). However, I still get the following:

File c:\Users\...\miniconda3\envs\py38\lib\opensim\__init__.py:7
5 os.add_dll_directory(os.path.dirname(os.path.realpath(__file__)))
6 else:
----> 7 os.add_dll_directory(DLL_PATH)
9 from .simbody import *
10 from .common import *

NameError: name 'DLL_PATH' is not defined

Is there a solution?

**Just to mention -- I do not have the same problem with installing openism without moco in the same environment...

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

Re: MocoCasADiSolver is not available in python

Post by Mohammadreza Rezaie » Tue Dec 05, 2023 4:21 am

Hi, the issue of DLL_PATH was fixed in the 4.4.1 version, which can be installed by:

Code: Select all

conda install -c opensim-org opensim-moco=4.4.1
Also, make sure that the miniconda paths exist in your environment path, e.g.:

Code: Select all

\miniconda3
\miniconda3\Scripts
\miniconda3\Library\bin
\miniforge3\Library\usr\bin
\miniforge3\Library\mingw-w64\bin
Let me know how it goes.

User avatar
Ekaterina Stansfield
Posts: 9
Joined: Mon Jul 03, 2017 5:37 am

Re: MocoCasADiSolver is not available in python

Post by Ekaterina Stansfield » Sun Dec 10, 2023 12:53 am

Thank you -- this version required python 3.9, not 3.8 -- Once the correct environment was created, the installation was painless. Thanks again for your help.

User avatar
katya stansfield
Posts: 4
Joined: Mon Dec 02, 2019 8:39 pm

Re: MocoCasADiSolver is not available in python

Post by katya stansfield » Mon Dec 11, 2023 1:03 am

Is there any version of opensim-moco that can be installed on Unix?

POST REPLY