This indicates that something is not setup correctly between Python and MATLAB and is NOT something specific to py.dict.
My test case was wtf = py.list(1:2)
When you are specifying the Python path my understanding is the 3 problems you are most likely to see, if the executable exists, are either:
- An unsupported Python version : https://www.mathworks.com/support/requirements/python-compatibility.html
- A mismatch between 32 bit and 64 bit
- A mismatch between ARM and Intel. This was my problem. I think for 2023b macs MATLAB is running ARM (for apple silicon macs).
In python run:
import platform, subprocess
platform.processor()
If it comes back i386 (or not arm) then you are probably using an Intel compiled Python version. For me I had to download a new version of Anaconda Navigator being careful to download the "M1" version (they offer both M1 and Intel and both might install). From there I installed a new environment. This put together a new Python that was using arm.
In MATLAB this is now the line I have in my startup.m file:
pe = pyenv('Version','/opt/anaconda3/envs/sci3/bin/python');
Note sci3 is the name of my environment
../bin/python?