Page 1 of 1

Error related to scripting in python

Posted: Wed Oct 28, 2020 9:32 am
by xhua
Dear OpenSim expert

I am trying to use opensim scripting in python. I followed the instruction (Installing Anaconda and the "opensim" Python package, which can be found in website: https://simtk-confluence.stanford.edu:8 ... +in+Python) to setup the python scripting environment step by step. After that, when I run "import opensim" in python, it gave the following error:

Traceback (most recent call last):
File "D:\Xijin Hua_Cambridge project\Multibody dynamics model_ankle orthosis\Model_20201018_Gait simulation\Python programme\RRAModelModification.py", line 1, in <module>
import opensim
File "C:\Users\xh308\AppData\Local\Continuum\anaconda2\lib\site-packages\opensim-4.1-py2.7.egg\opensim\__init__.py", line 1, in <module>
from .simbody import *
File "C:\Users\xh308\AppData\Local\Continuum\anaconda2\lib\site-packages\opensim-4.1-py2.7.egg\opensim\simbody.py", line 18, in <module>
_simbody = swig_import_helper()
File "C:\Users\xh308\AppData\Local\Continuum\anaconda2\lib\site-packages\opensim-4.1-py2.7.egg\opensim\simbody.py", line 17, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\xh308\AppData\Local\Continuum\anaconda2\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: DLL load failed: The specified module could not be found.
[Finished in 0.224s]

I used 64-bit OpenSim and 64-bit python, and have set the OpenSim's DLLs on the Path:

User variable:
Path --> C:\OpenSim 4.1\bin

System variable:
path --> C:\OpenSim 4.1\bin

Could you please tell me how to solve this problem? Thank you very much in advance.

Best regards

Xijin

Re: Error related to scripting in python

Posted: Wed Oct 28, 2020 9:42 am
by aymanh
Hello,

Can you clarify which version of python you're trying to use? For reference, our continuous integration uses python 3.7 and python.org distribution.

Best regards,
-Ayman

Re: Error related to scripting in python

Posted: Wed Oct 28, 2020 3:56 pm
by xhua
Dear Ayman

Thank you very much for your kindly reply.

I reinstall an Anaconda (Anaconda3-2020.07-windows-x86-64) and python (python 3.8.3) and run "import opensim" in python again. this time it gives the following error:

Traceback (most recent call last):
File "D:\Xijin Hua_Cambridge project\Multibody dynamics model_ankle orthosis\Model_20201018_Gait simulation\Python programme\RRAModelModification.py", line 1, in <module>
import opensim
File "C:\Users\xh308\AppData\Roaming\Python\Python38\site-packages\opensim-4.1-py3.8.egg\opensim\__init__.py", line 1, in <module>
from .simbody import *
File "C:\Users\xh308\AppData\Roaming\Python\Python38\site-packages\opensim-4.1-py3.8.egg\opensim\simbody.py", line 18, in <module>
_simbody = swig_import_helper()
File "C:\Users\xh308\AppData\Roaming\Python\Python38\site-packages\opensim-4.1-py3.8.egg\opensim\simbody.py", line 17, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\xh308\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing _simbody: The specified module could not be found.
[Finished in 0.5s]

Still, I used 64-bit OpenSim and 64-bit python (python 3.8.3), and have set the OpenSim's DLLs on the Path:

User variable:
Path --> C:\OpenSim 4.1\bin

System variable:
path --> C:\OpenSim 4.1\bin

Could you please tell me how to solve this problem? Thank you very much in advance.

Best regards

Xijin

Re: Error related to scripting in python

Posted: Wed Oct 28, 2020 11:06 pm
by aymanh
Hi Xijin,

Python 3.8 is not supported by the tools we're using to make the OpenSim API available, if you can switch to python version 3.7 and retry, that would be great. We have an open issue to track this on github https://github.com/opensim-org/opensim-core/issues/2869 if you're interested in tracking progress.

Hope this helps,
-Ayman

Re: Error related to scripting in python

Posted: Thu Oct 29, 2020 6:07 am
by xhua
Hi, Ayman

Thank you very much for your kindly reply. The problem has been solved when I switch to python version 3.7. It is working well now. Your suggestions really help a lot and are highly appreciated.

Best regards

Xijin