If you installed the command line tools for Xcode, it currently installs Python 3.9.6 — a quite old distribution as it is current release from Python.org is now officially up to Python 3.12.2. The 3.9 binaries and libraries are linked from your ~/Library/Python/3.9 folder to the /usr/bin location. Apple disabled the scripting bridge for this distribution.
I have the command line tools for Xcode installed, not for the crippled 3.9 distribution but for Swiftc and Clang compilation environments. To stay current with Python, I download the Universal2 installer for Python 3.12.2 from Python.org which has a proper macOS package installer. It creates an /Applications/Python 3.12 folder, installs the Library in /Library/Frameworks/Python.framework and links the Python3, idle3, pip3, etc binaries into /usr/local/bin.
To avoid running Python 3.9.6 from scripts, or from the command line, you alter your PATH statement in the shell dot file (e.g. .bash_profile, .zshrc) to this:
export PATH=".:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:${PATH}"
Once you have made that change and saved the dot file, do the following to make that take effect in the current Terminal session for the appropriate shell in use:
source ~/.zshrc
source ~/.bash_profile
Any additional Python packages that you install with pip3 will go into the following location:
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages