Cannot import OpenSim module: "DLL load failed"

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Navid Roux
Posts: 4
Joined: Wed May 23, 2018 5:25 am

Cannot import OpenSim module: "DLL load failed"

Post by Navid Roux » Sat Jun 09, 2018 10:28 am

Solution: see post below!

Steps to reproduce:
  1. Install OpenSim 4.0.Beta to "C:\Program Files\OpenSim 4.0.Beta"
  2. Navigate to "C:\Program Files\OpenSim 4.0.Beta\sdk\python"
  3. Run "python setup.py install" (from a shell with elevated permissions since OpenSim was installed to C:\Program Files)
  4. Run "python" and then "import opensim". This leads to the error message below.
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import opensim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\tools\miniconda3\lib\site-packages\opensim-4.0-py3.6.egg\opensim\__init__.py", line 1, in <module>
from .simbody import *
File "C:\tools\miniconda3\lib\site-packages\opensim-4.0-py3.6.egg\opensim\simbody.py", line 18, in <module>
_simbody = swig_import_helper()
File "C:\tools\miniconda3\lib\site-packages\opensim-4.0-py3.6.egg\opensim\simbody.py", line 17, in swig_import_helper
return importlib.import_module(mname)
File "C:\tools\miniconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
(The last part of the last line is German and reads "The specified module could not be found".)

In step 4, before running Python, I also tried adding the following paths to PATH (in PowerShell) to no avail:

Code: Select all

$env:PATH += "C:\Program Files\OpenSim 4.0.Beta\bin;"
$env:PATH += "C:\Program Files\OpenSim 4.0.Beta\sdk\Simbody\bin;"
System:
  • Windows 10 64 bit
  • OpenSim 4.0.Beta 64 bit (the same issue happens if I manually compile OpenSim-core from GitHub with the source as of today)
  • python == Python 3.6.5, 64 bit, from Miniconda 64
I appreciate any help and hints for possible root causes!
Last edited by Navid Roux on Wed Jun 20, 2018 6:27 am, edited 1 time in total.

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Cannot import OpenSim module: "DLL load failed"

Post by Dimitar Stanev » Mon Jun 11, 2018 2:05 am

Hi,

It's probably a permission problem because you installed opensim in program files. I suggest that you should install opensim in a different directory.
Last edited by Dimitar Stanev on Mon Jun 11, 2018 8:23 pm, edited 1 time in total.

User avatar
Navid Roux
Posts: 4
Joined: Wed May 23, 2018 5:25 am

Re: Cannot import OpenSim module: "DLL load failed"

Post by Navid Roux » Mon Jun 11, 2018 10:17 am

mitkof6 wrote:
Mon Jun 11, 2018 2:05 am
Its probably a permission problem because you installed opensim in program files. I suggest that you should install opensim in a different directory.
I copied "C:\Program Files\OpenSim 4.0.Beta" to a path without spaces ("D:\Opensimbeta") and repeated all steps (python setup.py + setting environment variables) from my first post to no avail. Exactly the same error message appears.

I will try actually installing - as opposed to simply copying - OpenSim 4.0 Beta to another directory.
UPDATE
navid.roux wrote:
Mon Jun 11, 2018 10:17 am
I will try actually installing - as opposed to simply copying - OpenSim 4.0 Beta to another directory.
Sadly, the same error occurs, even with the same (or rather analgous, i.e. with the new install directory in mind) paths added to PATH.

Is it intended that there are only *.lib files inside OpenSim's Python package? See the following output:

Code: Select all

PS C:\tools\miniconda3\Lib\site-packages> Get-ChildItem -r opensim-4.0-py3.6.egg | Resolve-Path -Relative
.\opensim-4.0-py3.6.egg\EGG-INFO
.\opensim-4.0-py3.6.egg\opensim
.\opensim-4.0-py3.6.egg\EGG-INFO\dependency_links.txt
.\opensim-4.0-py3.6.egg\EGG-INFO\native_libs.txt
.\opensim-4.0-py3.6.egg\EGG-INFO\not-zip-safe
.\opensim-4.0-py3.6.egg\EGG-INFO\PKG-INFO
.\opensim-4.0-py3.6.egg\EGG-INFO\SOURCES.txt
.\opensim-4.0-py3.6.egg\EGG-INFO\top_level.txt
.\opensim-4.0-py3.6.egg\opensim\__pycache__
.\opensim-4.0-py3.6.egg\opensim\actuators.py
.\opensim-4.0-py3.6.egg\opensim\analyses.py
.\opensim-4.0-py3.6.egg\opensim\common.py
.\opensim-4.0-py3.6.egg\opensim\examplecomponents.py
.\opensim-4.0-py3.6.egg\opensim\simbody.py
.\opensim-4.0-py3.6.egg\opensim\simulation.py
.\opensim-4.0-py3.6.egg\opensim\tools.py
.\opensim-4.0-py3.6.egg\opensim\version.py
.\opensim-4.0-py3.6.egg\opensim\_actuators.lib
.\opensim-4.0-py3.6.egg\opensim\_actuators.pyd
.\opensim-4.0-py3.6.egg\opensim\_analyses.lib
.\opensim-4.0-py3.6.egg\opensim\_analyses.pyd
.\opensim-4.0-py3.6.egg\opensim\_common.lib
.\opensim-4.0-py3.6.egg\opensim\_common.pyd
.\opensim-4.0-py3.6.egg\opensim\_examplecomponents.lib
.\opensim-4.0-py3.6.egg\opensim\_examplecomponents.pyd
.\opensim-4.0-py3.6.egg\opensim\_simbody.lib
.\opensim-4.0-py3.6.egg\opensim\_simbody.pyd
.\opensim-4.0-py3.6.egg\opensim\_simulation.lib
.\opensim-4.0-py3.6.egg\opensim\_simulation.pyd
.\opensim-4.0-py3.6.egg\opensim\_tools.lib
.\opensim-4.0-py3.6.egg\opensim\_tools.pyd
.\opensim-4.0-py3.6.egg\opensim\__init__.py
.\opensim-4.0-py3.6.egg\opensim\__pycache__\actuators.cpython-36.pyc
.\opensim-4.0-py3.6.egg\opensim\__pycache__\analyses.cpython-36.pyc
.\opensim-4.0-py3.6.egg\opensim\__pycache__\common.cpython-36.pyc
.\opensim-4.0-py3.6.egg\opensim\__pycache__\examplecomponents.cpython-36.pyc
.\opensim-4.0-py3.6.egg\opensim\__pycache__\simbody.cpython-36.pyc
.\opensim-4.0-py3.6.egg\opensim\__pycache__\simulation.cpython-36.pyc
.\opensim-4.0-py3.6.egg\opensim\__pycache__\tools.cpython-36.pyc
.\opensim-4.0-py3.6.egg\opensim\__pycache__\version.cpython-36.pyc
.\opensim-4.0-py3.6.egg\opensim\__pycache__\__init__.cpython-36.pyc
UPDATE 2

Using the DLL dependency analyzer "Dependencies" on "[my Python install path]\Lib\site-packages\opensim-4.0-py3.6.egg\opensim\_common.pyd", I could determine that I am only missing "Python35.dll", see the attachment. (Note that I ran "Dependencies" with "[OpenSim Installation]\bin" being on the PATH.
OpenSim-missing-DLL.PNG
OpenSim-missing-DLL.PNG (39.84 KiB) Viewed 1493 times
Last edited by Navid Roux on Wed Jun 20, 2018 6:28 am, edited 2 times in total.

User avatar
Navid Roux
Posts: 4
Joined: Wed May 23, 2018 5:25 am

Re: Cannot import OpenSim module: "DLL load failed"

Post by Navid Roux » Wed Jun 20, 2018 6:25 am

Solution: Using Python 3.5 solved the problem.

@Admins/OpenSim Devs: Could the solution description be edited into Scripting in Python on OpenSim's wiki?

Detailed solution:
  1. Go to "[OpenSim installation directory]\sdk\python".
  2. Start a shell there and run "python setup.py install". (Be sure to use the same version as the one used for compiling the OpenSim bindings. For the pre-built Windows binaries for OpenSim 4.0 Beta from the website it is Python 3.5.)
  3. Now go to an arbitrary other directory (so that "import opensim" is not resolved locally in "sdk\python") in your shell.
  4. Add "[OpenSim installation directory]\bin" to the PATH environment variable.
  5. Start Python and enter "import opensim" in the interactive prompt. If this generates an error:
    • Run "python --version" to verify that you are really using Python 3.5 (or any other you built OpenSim with).
    • Run "where.exe OpenSim" to verify that OpenSim\bin is really on your PATH.
    • Run "where.exe python3.5.dll" to verify that the Python DLL is really on your PATH.
    • As a last resort, you can try analyzing the dependencies of the "*.pyd" files inside the installed OpenSim Python package. See my viewtopic.php?p=25204&sid=43f20c4c8c7af ... ]last post.

POST REPLY