Invalid active developer path when attempting to use python3 after upgrading to macOS Monterey?

This will download and install the command line toolkit and fix the problem.

You don't need Xcode, you can install the command line tools here, about 130MB.

If the above alone is not enough, also run the following commands:

xcode-select --install


Sometimes you have to reset it if you have more then one version installed.

sudo xcode-select --reset
sudo xcode-select --switch /Applications/ sudo xcode-select --switch /Library/Developer/CommandLineTools

See more information in apple documentation.