I don’t know anything about Python (or any other scripting languages), and I don’t know anything about the terminal, But I do know enough about web-searches and copy-paste to be a threat to my system.
I think I hosed Python while trying to get Marked2 working with CritMarkup on an M1 Mini. Many of my automation workflows stopped working (and I didn’t solve the Marked2 problem either). I am in way over my head and I don’t even know where to start to get back to normal. It looks like I have Python3 installed, but it may not be in the right location (or maybe it’s the wrong version?), and now I’m afraid that I will just make things worse if I keep mucking around…
I cannot help you solve the issue if the native Python installation is botched, but my advice is to always install programming languages via homebrew (and in the Python case, create virtualenvs) to avoid these undesirable situations.
Having messed mine up once I was able to restore it by reinstalling over the top of the system version.
From then on I use a virtual environment from within PyCharm. That keeps it cleaner and I can test my code on all the flavors of Python I am supporting. PyCharm supports a relatively easy way to set up the virtual environment I was able to just follow the help file to do it.