Python might not be up-to-date, so use opt_prefix

Fixes #24456.