As stated here: https://www.statology.org/chi-square-critical-value-python/ you are rather looking for this (Percent point function):
scipy.stats.chi2.ppf