OSError: MATLAB Engine API for Python DLL Load Failed on Import
16 views (last 30 days)
Show older comments
I have installed the MATLAB Engine API for Python per here. Despite my MATLAB (R2019b) and python (3.7.10) verisions being compatible per here, I am receiving a DLL load file error whenever I attempt to import the matlab.engine module. I have verifed that the matlabengineforpython package is installed in my python virtual envronment, as well as copied the tbb and tbbmalocc.dll files to the same directory as my python virutal envionrment python executable, per here, neither of which resolved the issue.
With that in mind, what could still be cuasing this import error, and how can I go about resolving it?
Traceback (most recent call last):
File "C:\Users\tmoline\Miniconda3\envs\solar3.7\lib\site-packages\matlab\engine\__init__.py", line 45, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "C:\Users\tmoline\Miniconda3\envs\solar3.7\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'matlabengineforpython3_7'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\tmoline\Miniconda3\envs\solar3.7\lib\site-packages\matlab\engine\__init__.py", line 61, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "C:\Users\tmoline\Miniconda3\envs\solar3.7\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
File "<frozen importlib._bootstrap>", line 583, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1043, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\tmoline\Miniconda3\envs\solar3.7\lib\site-packages\matlab\engine\__init__.py", line 64, in <module>
'MathWorks Technical Support for assistance: %s' % e)
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance: DLL load failed: The specified procedure could not be found.
0 Comments
Answers (1)
surya venu
on 12 Apr 2024
Hi,
To resolve this issue, you can try the following steps:
1) Make sure that the MATLAB root directory is correctly set in the environment variables. You can check this by running the following command in MATLAB:
matlabroot
2) Make sure that the MATLAB Engine for Python is installed in the correct directory. It should be installed in the site-packages directory of your Python installation.
3) Make sure that the TBB and TBBMalloc DLL files are in the same directory as the Python executable.
4) Try reinstalling the MATLAB Engine for Python.
Hope it helps.
0 Comments
See Also
Categories
Find more on Call MATLAB from Python 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!