How do I resolve a Python error when using the Cellpose library from the "Medical Imaging Toolbox Interface for Cellpose Library" support package with MATLAB R2024a on Ubuntu 24.04?

조회 수: 6 (최근 30일)

I am using the 'cellpose' library from the 'Medical Imaging Toolbox Interface for Cellpose Library' support package in MATLAB R2024a on a Linux machine with Ubuntu 24.04. I am also using the "mail" command from Linux to send email notifications about the status of my script.
Reproduction steps:
1. Use the "cellpose" function and "blockImage" to load an image.
2. Use the "mail" command to send the status of the scripts, setting a couple of environment variables programmatically as shown below:

if ~contains(ckMailAddr, '/usr/lib/x86_64-linux-gnu/libstdc++.so.6')
setenv('LD_LIBRARY_PATH', '/usr/lib/x86_64-linux-gnu');
setenv('LD_PRELOAD', '/usr/lib/x86_64-linux-gnu/libstdc++.so.6');
end
3. Finally, use the "apply" function on the image, which results in the following error stack when executing the script in parallel:

>> rethrow(e)
Warning: Unable to load Python object. Saving (serializing) Python objects into a MAT-file is not supported.
Warning: Unable to load Python object. Saving (serializing) Python objects into a MAT-file is not supported.
Error using parallel.FevalFuture/fetchNext
The function evaluation completed with an error.

Error in blockedImage/applyInParallelOverBlocks (line 2429)
%fetchNext(obj.Futures);

Error in blockedImage/applyCore (line 2384)
obj.applyInParallelOverBlocks(bimds, usrFcn, outputs, updateWaitBarFcn,....

Error in blockedlmage/apply (line 389)
[oneCallOutputs{:}] = obj.applyCore(usrFcn, params);

Error in oir2im2stats (line 50)
[bstats , bcount] = apply(bim, ...

Error in DAPICounting_Recursive_FINAL (line 258)
[count,stats,im,img0bj,errorCount] = oir2im2stats(currDir, cp, import, ...

Error in run (line 112)
evalin('caller', strcat(scriptStem, ';'));

Caused by:
Error using MWCellposeWrapper>runmodel (line 60)
Python Error: AttributeError: 'array.array' object has no attribute 'eval'

How can I resolve this issue?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2024년 12월 31일
The environment variables set in your script are used to load dynamic shared libraries. Setting these variables before calling the "cellpose" function can cause issues with shared libraries.
To resolve this issue, you can try either of the following workarounds:
  • Set the environment variables manually after the "cellpose" function is called.
  • Use a custom bash script to set the variables, ensuring that they do not affect MATLAB directly.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by