Matlab crashes when using a virtual environment as the python interpreter

5 visualizaciones (últimos 30 días)
Hi,
I want to use some python packages / custom code in a deployed matlab application (compiled via mcc). To avoid missing python installs on the target machine, i want to distribute a virtual envrionment with my compiled application such that my application is self-sufficient.
However, when i attempt to set my intepreter to the virtual environment and then call some py.funcname to load it, Matlab crashes completely silently with no error messages.
Note: i run this at Matlab startup. I'm using R2022a. Python = 3.9.7
I create a virtual env with cmd :
python --version
Python 3.9.7
python -m venv c:/users/joee/dev/testenv
The i start matlab and run :
pyenv(Version="C:\users\joee\dev\testenv\Scripts\python", ExecutionMode="OutOfProcess");
pyenv
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "C:\users\joee\dev\testenv\Scripts\python.EXE"
Library: "C:\Users\Joee\AppData\Local\Programs\Python\Python39\python39.dll"
Home: "C:\users\joee\dev\testenv"
Status: NotLoaded
ExecutionMode: OutOfProcess
result = py.math.sqrt(10); % Matlab crashes silently. Completely dies. No error messages, nothing.
What am i missing?
Edit : I just found this bug report for 2022a. I'll try the fix here and post the result if it works. https://uk.mathworks.com/support/bugreports/details/2721315

Respuestas (1)

Joe Elsom
Joe Elsom el 13 de Sept. de 2022
Okay, for anyone experiencing this issue with R2022a update 3 or below, follow the instructions on this bug report https://uk.mathworks.com/support/bugreports/details/2721315
I found, R2022a Update 5 actually solves this issue completely without needing to adjust the library path.

Categorías

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

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by