Was the environment already installed before the upgrade to Sonoma?
Was anaconda already installed before the upgrade to Sonoma?
If any of your answers is yes, then what might have happened is that the upgrade brought a different layout of the standard C header files than the ones that were expected by the things you had installed via anaconda. My recommendation would be to reinstall anaconda so that you make sure that it is aware of the layout used by Sonoma