Live data from Hacker News

Pyenv – lets you easily switch between multiple versions of Python

github.com

231–240 of 341 posts

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

#231

Earlier quoted context omitted.

So, what is "the tool for beginners fighting with python packaging problems"? That is, the pattern seems to be that someone mentions a solution, then a zillion responses as to why it sucks. Is there any tool or pair that sucks least for most cases and beginners? I get that every case is different, but perhaps there are some useful starting points?

You could just give up and resort to using Docker.

Using docker is not free, you are effectively trading one type of complexity for another.

And of course you'll have to make sure people equally have good practices, since incorrectly using sudo pip install in docker and not a venv are very common.

So again, one possible solution for a certain context, but I wouldn't sell that to most people. Certainly not to beginners.

People writing their pythonanywhere website won't pop up a container, won't they ?

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

#232
post #179

Earlier quoted context omitted.

If you don’t care which specific version of python you are using, do not use pyenv. You will know when you care. These days, doing common tasks, the constraint solver in poetry will often tell you: “Hey! I can’t find a version of sentencepiece with metadata that lets me combine this with python 3.12.2. Sorry! I give up!” Now, if you aren’t concerned with using your bare metal for CUDA or fancy new MPS or AMD stuff. J…

This kind of error surprises me: > I can’t find a version of sentencepiece with metadata that lets me combine this with python 3.12.2 I'm a reasonably advanced python user. I've shipped web apps, Desktop GUIs, cli-tools, and even written cpython extension modules for custom hardware control. I typically target the system `python3` of whatever linux distribution I'm shipping to and I use the system 'python3-virtualenv…

(Edit2 tl:dr: it’s that other package maintainers don’t always keep up with new semver constants in their metadata, particularly on anything cutting-edge)

It’s always the inclusion of a specific dependency we added for a feature, and based on that dev’s knowledge and experience. It’s often me, but not always.

This doesn’t happen in ecosystems with a base package versioning. This is arguably why anaconda became popular, and why we target base docker images of ubuntu.

Doesn’t work in complex deployments based on money rather than ideals, every time. At least in my career.

Edit: first time I dealt with this, we ended up forking a dependency chain instead of using pip. I lost that war and they ended up reviving a legacy PHP app instead of funding python dev.

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

#233

Earlier quoted context omitted.

Don't need any wrappers either. venv has been built into python for ages.

yes but `workon` is too good not to have

Looks like what could be a shell alias to cd and activate? I always keep a few tabs open to my repos folder, so not sure it would help me much. Doesn't seem to support fish, though activate does.

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

#235

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?

I remember when I was a childish Perl fan trading insults with the childish Python fans of the time, one of the things "they" always chided "us" about was that we had too many different ways to accomplish the same thing...

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

#236

I have to warn again users that think they have found the silver bullet that pyenv comes with a big caveat: it compiles python on your machine. The number of possible modes of failure in this situation is huge. See also: "Why not tell people to "simply" use pyenv, poetry or anaconda" https://www.bitecode.dev/p/why-not-tell-people-to-simply-use I'm not saying pyenv is not a useful tool, but it is not a tool for beginn…

What's the problem? The repo clearly states that you need to install such and such build prerequisites.

Also, the issues the article you link are things that damn near every programmer will eventually need to know. Things like PATH are IMO the basics -- if you don't understand this or how to `$packageManager install` something, you're gonna have a rough time programming in general, regardless of language.

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

#238
post #27

I think the only problem of pyenv is that you can't upgrade an old virtualenv to a newer Python version.

That has nothing to do with pyenv.

Also, this really isn't a problem -- just blast out of the old venv, make a new one with a new version, and you're good.

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

#239

Earlier quoted context omitted.

You don't even need virtualenv much less virtualenv wrapper. On Debian/Ubuntu distros (and most others, with small modifications) you just need python3-venv. Then create your venv with `python3 -m venv myenv` or `python3.11 -m venv my311venv` or whatever version of Python you need. Less is more!

Agreed, but `workon` is too convenient not to have

I reimplemented the parts of `workon` I actually used with a small shell function.

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

#240

Earlier quoted context omitted.

You could just give up and resort to using Docker.

Using docker is not free, you are effectively trading one type of complexity for another. And of course you'll have to make sure people equally have good practices, since incorrectly using sudo pip install in docker and not a venv are very common. So again, one possible solution for a certain context, but I wouldn't sell that to most people. Certainly not to beginners. People writing their pythonanywhere website won'…

For a beginner trying to run someone else's Python project, it is free. You run one command and it works. There's tons more complexity under the hood, but you don't have to deal with it. This is why so many Python projects do resort to Docker.

And btw, JS doesn't have this problem, they use NPM.

Post reply on HN