Hi Joachim,
I located ngslib.pyd.
Dependencies worked better than Dependency Walker, but it doesn’t know about the paths that are set in the process of importing, so some non-problematic files were marked in red (not found). I made some screenshots (not attached).
I also found a python tool called dlltracer ( GitHub - microsoft/dlltracer-python: A DLL load tracing tool for CPython ). This I tried with a small script on both machines, the one where it works and the one where it fails. I will include below.
Basically you run “import ngsolve” in some kind of dlltrace context. The docs say that the import that causes the problem is not shown. The first import that is missing from the output of the machine where it fails is mkl_intel_thread.2.dll . So it appears that mkl files are the problem. On the other hand AFAICT the system finds at least one mkl file (mkl_rt.2.dll), but others are somehow not imported. Perhaps the one that is found is imported by some other component of netgen/ngsolve than the ones where it fails.
Chris
The script:
import os
import sys
import dlltracer
# # following doesn't make a difference
# mkl_bin_dir = "C:\\Users\\cstolk1\\Venv\\Library\\bin\\"
# os.add_dll_directory(mkl_bin_dir)
with dlltracer.Trace(out=sys.stdout):
import ngsolve
# with open("log_dlltrace_test5.txt", "w") as log:
# with dlltracer.Trace(out=log):
# import ngsolve
str = input("press enter")
The output when it works:
LoadLibrary C:\Windows\System32\kernel.appcore.dll
LoadLibrary C:\Users\ccsto\AppData\Local\Programs\Python\Python313\DLLs\_bz2.pyd
LoadLibrary C:\Users\ccsto\AppData\Local\Programs\Python\Python313\DLLs\_lzma.pyd
LoadLibrary C:\Users\ccsto\AppData\Local\Programs\Python\Python313\DLLs\_ctypes.pyd
LoadLibrary C:\Windows\System32\ole32.dll
...
LoadLibrary C:\Windows\System32\wintrust.dll
LoadLibrary C:\Windows\System32\imagehlp.dll
LoadLibrary C:\Windows\System32\crypt32.dll
LoadLibrary C:\Windows\System32\msasn1.dll
LoadLibrary C:\Users\ccsto\Work\Software\VenvNgsJax\Library\bin\mkl_rt.2.dll
LoadLibrary C:\Users\ccsto\Work\Software\VenvNgsJax\Lib\site-packages\ngsolve\ngslib.pyd
LoadLibrary C:\Users\ccsto\Work\Software\VenvNgsJax\Lib\site-packages\netgen\libngsolve.dll
LoadLibrary C:\Users\ccsto\Work\Software\VenvNgsJax\Library\bin\mkl_intel_thread.2.dll
LoadLibrary C:\Users\ccsto\Work\Software\VenvNgsJax\Library\bin\mkl_core.2.dll
LoadLibrary C:\Users\ccsto\Work\Software\VenvNgsJax\Library\bin\tbbmalloc.dll
press enter
The output when it fails:
LoadLibrary C:\Windows\System32\kernel.appcore.dll
LoadLibrary C:\Users\cstolk1\AppData\Local\Programs\Python\Python313\DLLs\_bz2.pyd
LoadLibrary C:\Users\cstolk1\AppData\Local\Programs\Python\Python313\DLLs\_lzma.pyd
LoadLibrary C:\Users\cstolk1\AppData\Local\Programs\Python\Python313\DLLs\_ctypes.pyd
LoadLibrary C:\Windows\System32\ole32.dll
...
LoadLibrary C:\Windows\System32\wintrust.dll
LoadLibrary C:\Windows\System32\imagehlp.dll
LoadLibrary C:\Windows\System32\crypt32.dll
LoadLibrary C:\Windows\System32\msasn1.dll
LoadLibrary C:\Users\cstolk1\Venv\Library\bin\mkl_rt.2.dll
LoadLibrary C:\Users\cstolk1\Venv\Lib\site-packages\ngsolve\ngslib.pyd
LoadLibrary C:\Users\cstolk1\Venv\Lib\site-packages\netgen\libngsolve.dll
Failed \Device\HarddiskVolume3\Users\cstolk1\Venv\Lib\site-packages\netgen\libngsolve.dll
Failed \Device\HarddiskVolume3\Users\cstolk1\Venv\Lib\site-packages\ngsolve\ngslib.pyd
Traceback (most recent call last):
File "C:\Users\cstolk1\TestNgSolve\test5.py", line 10, in <module>
import ngsolve
File "C:\Users\cstolk1\Venv\Lib\site-packages\ngsolve\__init__.py", line 38, in <module>
from .ngslib import __version__, ngstd, bla, la, fem, comp, solve
ImportError: DLL load failed while importing ngslib: A dynamic link library (DLL) initialization routine failed.