I believe I'm experiencing a bug in R2024a with py.list. After a clear all, I get the error No module or function named 'list'.:
clear all;res = py.list({"Name1","Name2","Name3"});
In this interface, the code runs just fine. When I run it locally, I get this:
>> clear all;res = py.list({"Name1","Name2","Name3"})
No module or function named 'list'.
I can get py.list to work again if I use another Python command. For example, this works:
>> handlers = py.logging.getLogger().handlers;
>> res = py.list({"Name1","Name2","Name3"});
>> clear all;res = py.list({"Name1","Name2","Name3"});
No module or function named 'list'.
I'm running MATLAB Version: 24.1.0.2628055 (R2024a) Update 4. I cannot replicate on R2023b.

 採用された回答

Steven Lord
Steven Lord 2024 年 7 月 23 日

0 投票

4 件のコメント

Tom Grieve
Tom Grieve 2024 年 7 月 23 日
編集済み: Tom Grieve 2024 年 7 月 24 日
Thank you! I don't know how I missed that bug report.
Steven Lord
Steven Lord 2024 年 7 月 24 日
If you searched the bug reports to try to find information about this bug, do you happen to remember what you searched for? Perhaps there's some words or phrases we could add to the report to make it more descriptive and/or discoverable.
Tom Grieve
Tom Grieve 2024 年 7 月 24 日
I can find the bug report now with no problem. I'm not sure what I was searching for, but I think I only used "python" as a keyword. I didn't connect my use of "clear all" with the behavior until after I searched, so the name of that bug report may not have meant anything to me.
Steven Lord
Steven Lord 2024 年 7 月 26 日
We tweaked the summary of the bug report to include part of the error message, hopefully that will make it more discoverable when people search for it.

サインインしてコメントする。

その他の回答 (1 件)

Avni Agrawal
Avni Agrawal 2024 年 7 月 23 日

0 投票

I understand that you are encountering an error when trying to access Python classes after using clear all in the command line for the R2024a release. I experienced a similar issue, and I found a workaround that worked for me. Executing clear classes allows MATLAB to locate and recreate the Python modules. For example:
clear all;res = py.list({"Name1","Name2","Name3"});
clear classes;
res = py.list({"Name1","Name2","Name3"});
I hope this helps!

1 件のコメント

Tom Grieve
Tom Grieve 2024 年 7 月 23 日
Thanks for your help! I'll have to try this workaround and see if it works better than mine for my application.

サインインしてコメントする。

カテゴリ

製品

リリース

R2024a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by