Matlab crashes when using a virtual environment as the python interpreter

조회 수: 4 (최근 30일)
Joe Elsom
Joe Elsom 2022년 9월 13일
답변: Joe Elsom 2022년 9월 13일
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

답변 (1개)

Joe Elsom
Joe Elsom 2022년 9월 13일
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.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by