Whether Xcode, or the command line tools for Xcode, they will install an older version of Python 3. With Xcode, the Python3 framework is internal to the Xcode application with a linked binary into /usr/bin/python3. This does not support the Python/Objective-C scripting bridge. I simply pretend this Python3 does not exist. As you should be aware, Apple removed the Python 2.7.18 distribution from Monterey 12.3.1 and later.
Instead, I install Python 3.10.6 (current) directly from Python.org using their installers. It has a universal2 build, a proper installer resulting in the Python3 installation into /Library/Frameworks/Python.framework/... and the automatically linked executables in /usr/local/bin. It does not step on the Apple Python3 bits, and with PATH changes, one avoids Apple's version altogether. One could even install Python 2.7.18 (though deprecated) in the same manner if migration from 2 to 3 still requires it.
Once one has the Python.org Python3 installed with that PATH adjustment, one can install Python3 compatible third-party solutions (e.g. pyobjc, pyinstaller, Qt6, etc.) without affecting Apple's bits.