pyenv and pyenv-virtualenv together solves this for me.
Virtualenv with specific python versions that work together well with other tools like pip or poetry.
You misunderstand, the first two commands are just one time setup to install a specific python version and then to create an env using that version. After that all you need is `pyenv activate myenv´ to drop you into that env, which will use the correct python version and make sure everything is isolated from other environments you might have.
You can also just create an env with the system python version, but the question was specifically about managing multiple versions of python side by side and this makes that super easy.
You could also combine it with direnv to automatically drop you into the correct environment based on the folder you are in, so you don’t have to type anything after the initial setup.
The issue is more general. When dealing with, say, apt, my experience is that nothing ever breaks and any false move is immediately recoverable. When dealing with Python, even seemingly trivial tasks inevitably turn into a broken mess of cryptic error messages and missing dependencies which requires hours of research to resolve. It’s a general complaint. The architecture seems fragile in some way. Of course, it’s possible it’s just because I am dumb and ignorant.
pyenv and pyenv-virtualenv together solves this for me. Virtualenv with specific python versions that work together well with other tools like pip or poetry.
It boils down to something like
$ pyenv install 3.12.7 $ pyenv virtualenv 3.12.7 myenv $ pyenv activate myenv
and at that point you can do regular python stuff like pip installing etc.
If you’re having to type out version numbers in your commands, something is broken.
I ended up having to roll my own shell script wrapper to bring some sanity to Python.
You misunderstand, the first two commands are just one time setup to install a specific python version and then to create an env using that version. After that all you need is `pyenv activate myenv´ to drop you into that env, which will use the correct python version and make sure everything is isolated from other environments you might have.
You can also just create an env with the system python version, but the question was specifically about managing multiple versions of python side by side and this makes that super easy.
You could also combine it with
direnv
to automatically drop you into the correct environment based on the folder you are in, so you don’t have to type anything after the initial setup.The issue is more general. When dealing with, say,
apt
, my experience is that nothing ever breaks and any false move is immediately recoverable. When dealing with Python, even seemingly trivial tasks inevitably turn into a broken mess of cryptic error messages and missing dependencies which requires hours of research to resolve. It’s a general complaint. The architecture seems fragile in some way. Of course, it’s possible it’s just because I am dumb and ignorant.