Currently available apparmor 3.1.4 has issues with aa-genprof with python 3.12 at least. There's also 3.1.7 maintenance release available (that might be preferred to 4.0 in the short term due to breaking changes introduced with 4.0).