Effacer les filtres
Effacer les filtres

No module named 'matlabrun​timeforpyt​hon3_9', when trying to run my packaged Matlab script

6 vues (au cours des 30 derniers jours)
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?

Réponses (1)

Yash Sharma
Yash Sharma le 20 Sep 2023
Modifié(e) : Yash Sharma le 20 Sep 2023
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:

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by