ich will aus einem Matlab-Skript heraus eine Python-Funktion ausführen, die wiederum mittels subprocess.call Matlab ausführt.
Hintergrund:
Ich will aus einer 64-Bit-Version von Matlab die 32-Bit-Version von Matlab zentral ausführen um ein 32-Bit-Simulink-Modell auszuführen. Daher brauche ich Python als Middleware.
Hier mein Code im Matlab-Skript:
Code: Alles auswählen
clear classes
mod = py.importlib.import_module('funktionen');
py.importlib.reload(mod);
py.funktionen.simStartParkTEST() %Hier wird die Python-Funktion ausgeführt
Code: Alles auswählen
def simStartParkTEST():
""" simuliert einen Park """
import subprocess
subprocess.call([r"C:\Program Files (x86)\MATLAB\R2012b\bin\matlab.exe","-nosplash", "-nodesktop","-wait","-softwareopengl", "-r","disp('Hallo')"])
#subprocess.call([r"C:\Program Files (x86)\MATLAB\R2012b\bin\matlab.exe","-nosplash", "-nodesktop","-wait","-softwareopengl", "-r","disp('Hallo')"],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
print("DONE simStartPark4")
Wenn ich die Python-Funktion direkt aus Python starte, erhalte ich diesen Fehler nicht!Error using subprocess>_make_inheritable (line 1062)
Python Error: OSError: [WinError 6] Das Handle ist ungültig
Error in subprocess>_get_handles (line 1050)
errwrite = self._make_inheritable(errwrite)
Error in subprocess>__init__ (line 813)
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
Error in subprocess>call (line 535)
with Popen(*popenargs, **kwargs) as p:
Error in funktionen>simStartParkTEST (line 164)
subprocess.call([r"C:\Program Files (x86)\MATLAB\R2012b\bin\matlab.exe","-nosplash",
"-nodesktop","-wait","-softwareopengl", "-r","disp('Hallo')"],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
Weiss jemand, warum bei Ausführen aus Matlab heraus sich der Fehler Python Error: OSError: [WinError 6] Das Handle ist ungültig einstellt und was dieser zu bedeuten hat?