Page 1 of 1

MocoCasADiSolver is not available in python

Posted: Sat Nov 25, 2023 6:14 am
by ebulygin
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?

Re: MocoCasADiSolver is not available in python

Posted: Sun Nov 26, 2023 8:55 am
by kernalnet
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>')

Re: MocoCasADiSolver is not available in python

Posted: Tue Dec 05, 2023 4:08 am
by katyastansfield
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...

Re: MocoCasADiSolver is not available in python

Posted: Tue Dec 05, 2023 4:21 am
by kernalnet
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.

Re: MocoCasADiSolver is not available in python

Posted: Sun Dec 10, 2023 12:53 am
by ebulygin
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.

Re: MocoCasADiSolver is not available in python

Posted: Mon Dec 11, 2023 1:03 am
by katyastansfield
Is there any version of opensim-moco that can be installed on Unix?