PyEnv takes the awful parts of Python environment management and makes them decidedly not awful.
Not the sort of thing you’d force into conversation at a party, but getting this set up will really improve your Python experience.
I learned about PyEnv during the twilight chapters of my Brownie days. When I first started using the tool, Python 3.9 was typically available on most Linux installations. Installing Brownie was simple, just run a bit of pip install
magic and you were good to go. The eventual upgrade to Python 3.10 was fairly painless, too, assuming you already had a working Python 3.9 virtual environment. A fresh install with Python 3.10 was a different matter, of course.
Eventually I wanted to upgrade my OS to a release with Python 3.11 as the system default, so I needed a real solution that would let me continue using Python 3.9 for my Brownie tooling.
There are other options for managing multiple Python versions, including Conda/Miniconda. I tried Conda first because I’d used it on Windows many years ago, but finally chose PyEnv after giving it a serious test run.
PyEnv is designed to work correctly on a POSIX/UNIX-style system, which means native Linux or MacOS via homebrew. Apparently PyEnv can work on Windows through WSL, but I have no experience with that and recommend that Windows users just stick with Conda.
Installing PyEnv
Simply follow the installation instructions on the PyEnv Github page and you should be set without much trouble.
PyEnv relies on a set of “shims” that intercept calls to Python and dispatch them to the appropriate version inside a running shell. They are critical and must be functional for anything PyEnv-related to work.