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?

8 ビュー (過去 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 Center および File ExchangeCall 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