SDFIdk / DHMQC

Processing suite for the Danish Digital Elevation Model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not find module libdelaunator.dll

remamsdfe opened this issue · comments

Windows: Python 3.8.1

ERROR: Failure: FileNotFoundError (Could not find module 'C:\DHMQC\qc\thatsDEM\lib\libdelaunator.dll'. Try using the full path with constructor syntax.)

Traceback (most recent call last):
File "C:\Users\b025527.conda\envs\DHMQC\lib\site-packages\nose\failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "C:\Users\b025527.conda\envs\DHMQC\lib\site-packages\nose\loader.py", line 416, in loadTestsFromName
module = self.importer.importFromPath(
File "C:\Users\b025527.conda\envs\DHMQC\lib\site-packages\nose\importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "C:\Users\b025527.conda\envs\DHMQC\lib\site-packages\nose\importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "C:\Users\b025527.conda\envs\DHMQC\lib\imp.py", line 234, in load_module
return load_source(name, filename, file)
File "C:\Users\b025527.conda\envs\DHMQC\lib\imp.py", line 171, in load_source
module = _load(spec)
File "", line 702, in _load
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\DHMQC\tests.py", line 8, in
from qc.thatsDEM import triangle
File "C:\DHMQC\qc\thatsDEM\triangle.py", line 48, in
delaunator_lib = ctypes.cdll.LoadLibrary(delaunator_lib_name)
File "C:\Users\b025527.conda\envs\DHMQC\lib\ctypes_init
.py", line 451, in LoadLibrary
return self.dlltype(name)
File "C:\Users\b025527.conda\envs\DHMQC\lib\ctypes_init
.py", line 373, in init
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\DHMQC\qc\thatsDEM\lib\libdelaunator.dll'. Try using the full path with constructor syntax.

Appears to be caused by this change introduced in Python 3.8:

DLL dependencies for extension modules and DLLs loaded with ctypes on Windows are now resolved more securely. Only the system paths, the directory containing the DLL or PYD file, and directories added with add_dll_directory() are searched for load-time dependencies. Specifically, PATH and the current working directory are no longer used, and modifications to these will no longer have any effect on normal DLL resolution. If your application relies on these mechanisms, you should check for add_dll_directory() and if it exists, use it to add your DLLs directory while loading your library. Note that Windows 7 users will need to ensure that Windows Update KB2533623 has been installed (this is also verified by the installer). (Contributed by Steve Dower in bpo-36085.)

Strangely enough, this only seems to affect libdelaunator.dll, not the other DLLs in that directory.

Sigh... This error seems to be another case of misleading "missing DLL" messages on Windows.

Unlike the other DLLs in its directory, libdelaunator.dll currently has dependencies on DLLs for MinGW's C and C++ standard libraries.

The error message masks the actual error, which is failure to resolve those MinGW DLLs (on my machine, libgcc_s_seh-1.dll and libstdc++-6.dll) under Python 3.8's stricter rules.

As a workaround for now, DHMQC can be installed in an Conda environment with Python pinned to 3.7 (add python=3.7 to the packages to install).

Behaviour regarding the misleading error message reported to Python's issue tracker here: https://bugs.python.org/issue39393

It seems only Python 3.8 (and not 3.9+) is fussy about DLL paths here, so I'm going to take the easy way out and support only 3.9 and 3.10 😄