MacOS -- Cleanup after after installing pyenv and, with it, 3.9 to upgrade from 3.8?

Caution: just getting started with python. MacOS 10.15.7 (Catalina)

I had 3.8.2 installed. I have a /usr/bin/python which is 3.8.2; I probably renamed or re-aliased it to “python” some time ago. Today, I downloaded and installed 3.9.2. Then I found and followed The right and wrong way to set Python 3 as default on a Mac, which advises using Homebrew to install pyenv and then use pyenv to install python 3.[latest]. I did that, and then a “pyenv global 3.9.2”. So I might have two of python 3.9.2, one from the installer and one from pyenv? (The installer put a “Python 3.9” folder in my Applications folder; it contains an and various docs and commands.) In any case I still have 3.8.2 and perhaps earlier versions… I see that in /usr/local/bin I have pip, pip3, pip3.8, and pip3.9.

If nothing else, I’d like to free disk space that will never be used. What should I do to clean up any mess that I’ve made? Also, I’d like to type something shorter than “python3.9” to run it from zsh.

You probably haven’t made a mess. Multiple Python versions can co-exist on the same system, including the Apple-provided Python 2.7 at /usr/bin/python, something you shouldn’t try to change (and can’t easily change on 10.15). If you used a installer for a Python 3 version, you should be able to invoke it by typing python3 from the command line (rather than python). If you are running within a virtual environment, python would also work. There’s nothing wrong with either using the version or using a version from Homebrew, MacPorts, or other third-party distributor with or without pyenv; it’s all a matter of preference. Currently, the installers do not provide an uninstall script but you could adapt the suggestion here.

If you use Homebrew, it recommends installing the command line tools for development (run “brew doctor” to check)
Only after you did this you will have /usr/bin/python3.
I always use that one in a virtual env as I mostly develop for Debian Stretch or Buster and 3.6 is the freshest Python version which comes out of the box for these two anyways so macOS’s 3.8 is current enough for development. For checking problems I use a docker container which runs the tests (as well as in CI)