The error you’re getting is a Python based error suggesting you’re already running some form of interactive Python. Try to
exit() out of it to return to the normal terminal and you should get your normal prompt back.
If this is mac then unless it’s changed recently I believe they have python pre-installed as part of the system that you probably don’t want to use. Try
python -V (once you’re back in the normal terminal shell) and if it’s version 2.7.xx of some sort then that’s probably the pre-isntalled version.
Since you’ve installed python 3.9 try running
python3 -V to test if the new version was added to the path with this name. You’d want to be working with this version.
If you’d rather not used
python3 as a command to call the program then consider something like
pyenv to sort your shell environment out for you. You may want to hunt down a guide to do this step.