DLL fails to load - matlabrunt​imeforpyth​on_abi3

Hi all,
I've been struggling with this one for a few days now. I'm looking for proof of concept program that I can package a matlab function and then import it to my python executable. So far everything runs great in a terminal, but after using PyInstaller to generate the executable the I cannot get it to run. I've installed the MATLAB 2025b runtime and did install the package that was generated using the Python Package Compiler in MATLAB.
I get the following output in my command window when I attempt to launch matlab_test.exe:
My MATLAB function:
function a = matlab2python(b)
a = sqrt(b);
end
My python code:
import os
import sys
import time
import matlabsdk as sdk_python_test
import matlab
if __name__ == "__main__":
pkg = sdk_python_test.initialize()
result = pkg.matlab2python(9.0)
print(result)
pkg.terminate()

Risposte (1)

Isha
Isha il 16 Mar 2026 alle 9:36
Hello,
When you run your script in a terminal, it works because all MATLAB Runtime DLLs are on your system and discoverable via PATH.
When you run the ‘PyInstaller’ executable, it fails because ‘PyInstaller’ does not know to include the necessary MATLAB Runtime DLLs. The DLL search path is different for frozen apps.
If you have multiple runtimes installed, remove older ones from your PATH to avoid confusion and make sure your MATLAB Runtime version matches exactly what your SDK package was built with (R2025b).
Hope this helps.

1 Commento

Craig
Craig il 16 Mar 2026 alle 18:41
I've followed both of those guides and the R2025b runtime is the only one installed.
I've added the runtime location to the system path, same issue.
The ImportError still pops up for missing the matlabruntimeforpython_abi3 module. I look in the runtime library and the file does exist, so I'm not sure what else I'm missing

Accedi per commentare.

Categorie

Prodotti

Release

R2025b

Richiesto:

il 11 Mar 2026 alle 14:48

Commentato:

il 16 Mar 2026 alle 18:41

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by