Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
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.
When you come across some Python code for something written 5 years ago and they used four contributed packages that the programmers have changed the API on three times since then, you want to set up a virtual environment that contains those specific versions so you can at least see how it worked at that time. A small part of this headache comes from Python itself mutating, but the bulk of the problem is the imported user-contributed packages that multiply the functionality of Python.
To be sure, it would be nice if those programmers were all dedicated to updating their code, but with hundreds of thousands of packages that could be imported written by volunteers, you can’t afford to expect all of them them to stop innovating or even to continue maintaining past projects for your benefit.
If you have the itch to fix something old so it works in the latest versions of everything, you have that option… but it is really hard to do that if you cannot see it working as it was designed to work when it was built.
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.When you come across some Python code for something written 5 years ago and they used four contributed packages that the programmers have changed the API on three times since then, you want to set up a virtual environment that contains those specific versions so you can at least see how it worked at that time. A small part of this headache comes from Python itself mutating, but the bulk of the problem is the imported user-contributed packages that multiply the functionality of Python.
To be sure, it would be nice if those programmers were all dedicated to updating their code, but with hundreds of thousands of packages that could be imported written by volunteers, you can’t afford to expect all of them them to stop innovating or even to continue maintaining past projects for your benefit.
If you have the itch to fix something old so it works in the latest versions of everything, you have that option… but it is really hard to do that if you cannot see it working as it was designed to work when it was built.