No module named 'matlabruntimeforpython3_9', when trying to run my packaged Matlab script
8 views (last 30 days)
Show older comments
I have Matlab Runtime v911 installed and have compiled a script with a sample file to call it.
I had an issue however when I try to import the function with Runtimes.
from __future__ import print_function
import load_function
import matlab
On the second import I keep getting the error -> No module named 'matlabruntimeforpython3_9'. I have tried using sys.path.append() and the like in the packaged script but I keep ending up with the same error.
Is there any way to fix this?
0 Comments
Answers (1)
arushi
on 5 Sep 2024
Hi George,
I understand that you are encountering an issue while attempting to establish a connection between MATLAB runtime and Python. To resolve this, please verify whether your MATLAB version is compatible with Python 3.9. It is important to note that MATLAB supports Python 3.9 starting from R2021b and later versions. If you are using an earlier version of MATLAB, you may need to consider upgrading to a compatible version to ensure smooth integration with Python 3.9.
You can also explicitly specify MATLAB runtime path in your Python script, before importing the load_function module, by using the os.environ dictionary. Replace <matlab_runtime_path> with the actual path to your MATLAB Runtime installation directory.
import os
os.environ['PATH'] = '<matlab_runtime_path>;' + os.environ['PATH']
For detailed information on which MATLAB version supports specific Python versions, you can refer to the following link:
Hope it helps.
0 Comments
See Also
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!