Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
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?

Respuestas (1)

Yash Sharma
Yash Sharma el 20 de Sept. de 2023
Editada: Yash Sharma el 20 de Sept. de 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:

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by