Error 127 Details: Unable to load bundle binary C:\Program Files\MATLAB\R2020b\bin\win64\builtins\matlab_toolbox_general_builtins\mwwkspintrospect_builtinimpl.dll
Show older comments
I have compiled a python package for a matlab function. But when i run the same by initializing the mcr instance in python i get the error below. I suspect that the startup.m script is not being called and hence Matlab is not able to find the .dll file. How can this be fixed ?
I get this error while executing the matlab function from a flask app. But it runs without any errors when executed through a standalone python script or through the interpreter.
PS: I have a feeling that if i somehow call startup.m in my main function then it should solve the problem.
File "C:\Program Files\MATLAB\R2020b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\deployablefunc.py", line 80, in __call__
nlhsWasSpecified, stdoutObj, stderrObj).result()
File "C:\Program Files\MATLAB\R2020b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\futureresult.py", line 135, in result
raise e
File "C:\Program Files\MATLAB\R2020b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\futureresult.py", line 123, in result
raise e
File "C:\Program Files\MATLAB\R2020b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\futureresult.py", line 113, in result
self._nlhs, out=self._out, err=self._err)
matlab_pysdk.runtime.MatlabRuntimeError: An error occurred when evaluating the result from a function. Details: Unable to load bundle binary C:\Program Files\MATLAB\R2020b\bin\win64\builtins\matlab_toolbox_general_builtins\mwwkspint
rospect_builtinimpl.dll. Error: 127: state not recoverable
Answers (2)
Priysha LNU
on 7 Oct 2020
2 votes
This issue is potentially caused by spaces in the Windows "%temp%" directory path. Once your Windows "%temp%" directory path does not have a space, the script should be able to execute without error. Spaces in the Windows "%temp%" directory may be caused by spaces in the Windows username.
Here "C:\Program Files\" seems to contain a space character. Changing to a directory without the "space character" in the path might help resolve this issue.
This is a known issue and you can find a workaround in the following bug report:
DISCLAIMER: These are my own views and in no way depict those of MathWorks.
10 Comments
Mehul Garg
on 9 Oct 2020
Brian Andersen
on 15 Jan 2021
And where are these corresponding variables?
Shriram TG
on 19 Feb 2021
you can edit environment variables by searching 'Edit the environment Variables' in windows 10 -> advanced -> system variables
I'm getting the same error, but in a different situation. I don't have a flask application, but depending on which packages I use in Python, I get the same error as the OP. Very weird. And yes, it's not acceptable that MATLAB (still) has issues with white spaces in the path. Uninstalling and reinstalling a big software like MATLAB isn't always an easy task when IT is in the picture. And that becomes a requirement for deployment (user shall not install MATLAB in a path with white spaces).
Quick update. After reinstalling MATLAB, I'm still getting the same error. I created a Python Package using the compiler library, which I then import in the Python code. I first call initialize() and then I call the main function in the package. And that's when the error occurs. All relevant paths have no white spaces.
Caught "std::exception" Exception message is:
Unable to load bundle binary C:\MATLAB\R2020b\bin\win64\builtins\matlab_toolbox_general_builtins\mwwkspintrospect_builtinimpl.dll. Error: 127: state not recoverable
Traceback (most recent call last):
...
File "C:\MATLAB\R2020b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\deployablefunc.py", line 79, in __call__
ret = futureresult.FutureResult(self._cppext_handle, future_tuple, nlhs,
File "C:\MATLAB\R2020b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\futureresult.py", line 135, in result
raise e
File "C:\MATLAB\R2020b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\futureresult.py", line 123, in result
raise e
File "C:\MATLAB\R2020b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\futureresult.py", line 112, in result
self._result = self._cppext_handle.getFEvalResult(self._future_tuple,
matlab_pysdk.runtime.MatlabRuntimeError: An error occurred when evaluating the result from a function. Details: Unable to load bundle binary C:\MATLAB\R2020b\bin\win64\builtins\matlab_toolbox_general_builtins\mwwkspintrospect_builtinimpl.dll. Error: 127: state not recoverable
This error happens when using Fedot (https://github.com/nccr-itmo/FEDOT). Not sure what the problem is.
After a lot of debugging, I realized that the "std::exception" happens when I call fileread in the MALTAB function. And it makes no sense because everything works fine if I use an AutoML framework other than Fedot. if I instantiate class Fedot after running the MATLAB function, then it works fine. And that's the "fix" to my problem. I can't instantiate Fedot before calling the MATLAB function. Very weird.
I now suspect it may have to do with Tensorflow. Whenever it is imported in Python, I get the following warnings:
2021-08-12 14:52:01.983359: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-08-12 14:52:01.983479: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
And if that happens before I call the MATLAB function, I get the same error. So the "solution" now seems to first call the MATLAB function and then import anything related to Tensorflow. There's some interference going on.
Antony Smith
on 28 Nov 2022
If this is an issue with the space in "Program Files" then that is clearly a major bug in the installation of Matlab.
A while back I had this issues and it took me days to figure out the cause was the space in my User Account name. To solve it I had to create a new User Account with a single word name.
Now I have gotten a new laptop and installed Matlab on the single named user account, which ran fine at first. After several hours of installing all of the required Add-Ons and libraries, I switch my laptop on today and when trying to create new Simulink file, I am getting the Error:
Failed to load bundle #441: C:\Program Files\MATLAB\R2022b\bin\win64\dastudio.dll
I REALLY do not want to uninstall and go through all of this again.
How can Matlab overlook something as obvious as a SPACE character in the file recall system. Especially when it is the one that chose the installtion path of "C:/Program Files"???
Has nobody figured out a quicker work around for this sissue?
Gary
on 18 Mar 2023
reinstall all the matlab with path without space, still not Ok. Error still.......
weiliang
on 22 Jul 2024
i have no idea......
Mohammad
on 20 Dec 2023
1 vote
how can matlab overlook this problem? i still face similar issue with no solution
Categories
Find more on Python Package Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!