Live data from Hacker News

Pyenv – lets you easily switch between multiple versions of Python

github.com

181–190 of 341 posts

Re: Pyenv – lets you easily switch between multiple versions of Python

#181
I wonder if it ever occurs to people the whole concept of versioned environments for compatibility is fundamentally a terrible design kludge.

Someone needs to standardize a single Python environment at least annually. As these tools are just turning Python into a perpetual Alpha build.

Best of luck, =)

Re: Pyenv – lets you easily switch between multiple versions of Python

#182
I long for the day when python is mature enough for an implementation to arise where one binary can run as all previous versions of the language and stdlib, so you can do

    allpy --std=py3.4
and have it "just work", in the same sort of way that you can currently do

    gcc -std=c90

(And also therefore `#!/usr/bin/allpy --std=py3.4`)

I mean, imagine if C compilers required that you have a separate compiler binary and copy of the standard headers (or even worse, all of stdlib!) for each version of the C standard?!? Instead of just putting new language features on version flags, and make stdlib functions available/marked as deprecated based on version checks?

Re: Pyenv – lets you easily switch between multiple versions of Python

#183

Tools you can use to make sure the Python program you wrote keeps working: requirements.txt, pip, pipenv, pyenv, virtualenv, pyenv-virtualenv, virtualenvwrapper, pyenv-virtualenvwrapper, venv, pyvenv, conda, miniconda, poetry, docker, nix. Which ones did I miss? Which of them actually ensure your program always works the same as when you first wrote it, without asterisks?

None. The software container image is the best bet but you need to keep the image and not only the building scripts.

This is not true. Nix actually solves the problem. If you package with Nix, you'll get the exact same version of Python with the exact same version of dependencies, including the exact same version of system libraries. Your build will work in a year just as it does today. You don't even need to keep any binary artifacts.

Of course this doesn't come free: packaging with Nix may involve nontrivial effort for some projects.

Re: Pyenv – lets you easily switch between multiple versions of Python

#184

Earlier quoted context omitted.

Yeah, ASDF is fantastic, I'm glad stuff like pyenv and rvm existed and paved the way for it but ASDF is the way to go nowadays.

asdf for python is a wrapper around pyenv, it didn't "pave the way", it's an important part of asdf. (Also I like mise better currently: https://github.com/jdx/mise )

Well that's excellent!

Re: Pyenv – lets you easily switch between multiple versions of Python

#185

I long for the day when python is mature enough for an implementation to arise where one binary can run as all previous versions of the language and stdlib, so you can do allpy --std=py3.4 and have it "just work", in the same sort of way that you can currently do gcc -std=c90 (And also therefore `#!/usr/bin/allpy --std=py3.4`) I mean, imagine if C compilers required that you have a separate compiler binary and copy o…

I wonder if "maturity" is the problem, or just different design goals. You speak like this is an inherent feature that comes with some magical level of "maturity", but if the feature isn't a legitimate design goal of the product, it isn't "immature" not to have it.

Re: Pyenv – lets you easily switch between multiple versions of Python

#186

I used pyenv in my previous company. At first it was fine, but after a while with multiple versions of Python installed, things stopped working. The right virtual env was not activated, etc. (It could have also been because our software updates like OS and security upgrades were pushed by desktop support). I removed all of it, and just resorted to installing multiple versions of Python the old way (downloading from p…

Works fine for me on macOS. I am using venv the same way you do except some global ones for certain tools.

Also, when working on packages supporting multiple versions it was very helpful to use tox with pyenv.

Re: Pyenv – lets you easily switch between multiple versions of Python

#187
pip+venv mostly work fine for me, but there are some libraries like say numpy/scipy that are heavy so I want to share them across projects instead of installing multiple copies. I use pyenv to create a python version separate from the system version and install global dependencies into that. It's been useful for that and is just a nice way to manage multiple versions of python. So pyenv is a great addition to the traditional pip+venv setup.

unrelated rant -

Why is the "requirements.txt" file a stupid flat listing of all transitive dependencies with pinned versions? It makes it harder to change library versions even if there are no true conflicts. I've resorted to making an "actual_requirements.txt" file manually listing only direct dependencies and whatever version constraints make sense. I wish pip would fix this.

Re: Pyenv – lets you easily switch between multiple versions of Python

#188
I've been using python on and off since Django 0.96, which was released in 2007.

I don't recall ever needing anything other than virtualenvwrapper and pip—and even some of the annoyances these tools had early on have been solved by now...

https://virtualenvwrapper.readthedocs.io/en/latest/

If you really need different versions of python, you can just `mkvirtualenv -p python3 venvname`

I feel like every other tool out there has to explain what problem they solve that virtualenvwrapper doesn't

Don't install anything globally, creates lots of envs, and feel free to have different versions of python installed side-by-side with some "main" version preferably symlinked as `python` and `python3`

The end

Re: Pyenv – lets you easily switch between multiple versions of Python

#189

Tools you can use to make sure the Python program you wrote keeps working: requirements.txt, pip, pipenv, pyenv, virtualenv, pyenv-virtualenv, virtualenvwrapper, pyenv-virtualenvwrapper, venv, pyvenv, conda, miniconda, poetry, docker, nix. Which ones did I miss? Which of them actually ensure your program always works the same as when you first wrote it, without asterisks?

You only need pip and virtualenvwrapper

requirements.txt is a text file, not a separate tool...

if you want your program to work exactly as intended in the future, there are tools like py2exe and py2app for that.

Re: Pyenv – lets you easily switch between multiple versions of Python

#190

I used pyenv in my previous company. At first it was fine, but after a while with multiple versions of Python installed, things stopped working. The right virtual env was not activated, etc. (It could have also been because our software updates like OS and security upgrades were pushed by desktop support). I removed all of it, and just resorted to installing multiple versions of Python the old way (downloading from p…

Works fine for me on macOS. I am using venv the same way you do except some global ones for certain tools.

I thought one of the advantages of pyenv was that you switched to also creating virtual envs using pyenv and managed virtual environments with it too. Maybe not.
Post reply on HN