Live data from Hacker News

Pyenv – lets you easily switch between multiple versions of Python

github.com

151–160 of 341 posts

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

#151

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…

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.

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

#153

Earlier quoted context omitted.

What does poetry deliver beyond what pyenv gets you? I haven't used either tool super extensively.

pyenv only manages python versions, while poetry manages dependencies and virtual environments. They are complimentary, but do not overlap.

To add to this, with poetry, you basically do `poetry env use python3.12` to create a python virtualenv on python3.12 (you can use whatever python version pyenv supports, doesn't even have to be CPython).

The generated virtual env name is a little wonky. I'm not sure exactly what the scheme is, but it's basically `$(package)-$(some sort of hash?)-$(pyversion)`. I can't speak for all tools, but at least VS Code detects the poetry env and suggests it (and indicates it as a Poetry env) when you go to configure the project interpreter.

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

#154

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 have been looking at Rye, I like it so far.

The other one is Docker, which some people hate. I don't mind it, in some cases I prefer it.

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

#155
post #75

Python (and Ruby) handling of versions and dependencies is truly awful... :-(

How is it awful on the Ruby side? In my experience it is a solved problem since bundler was invented 15 years ago. It's been very free from pain during the last 10 years or so.

AFAIR it was mostly because Ruby still wanted to use not-100%-fixed versions so there was still an issue with something updating slightly breaking the build. Just a cursory experience when trying to deal with Ruby. Though it _felt_ somewhat more stable than Python.

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

#156
I recently used Pyenv to install an older version of Python on my system. The reason for this, is I wanted to create a Docker image using 3.8 slim-buster and I wanted to be explicit about the Python libraries I needed. By using Pyenv to install the same version of python as is used by slim-buster I was able to pip freeze my virtual env, and use the same version of libraries for the Docker image no problem. Oh the things I have to do in Python to avoid dependency hell

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

#157

Earlier quoted context omitted.

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 )

Curious what you like about mise! I've been a strong advocate for asdf for a few years now. Aside from smooshing together tools that are often used together, but not always (direnv, make), I can't see what mise adds to the picture. And I like still having direnv for what direnv does and make for make does, rather than an all-in-one.

the asdf CLI has really sharp edges and feels kind of aggressively unhelpful.

Even if you just use mise as an asdf alternative, it has a nicer CLI and interacts with the same plugin ecosystem more smoothly.

(I've found it to be an improvement on direnv, but I still use make)

the comparison to asdf page has more: https://mise.jdx.dev/dev-tools/comparison-to-asdf.html

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

#158
post #121

Earlier quoted context omitted.

That happens way more often than people want to admit, and I think it's not genuine to present the tool that way. E.G, I'm on Ubuntu 20.04 on an Dell XPS, a fairly standard machine, I'll get: pyenv install 3.9 -v /tmp/python-build.20240325124651.73089 ~ Downloading Python-3.9.19.tar.xz... -> https://www.python.org/ftp/python/3.9.19/Python-3.9.19.tar.xz ... LD_LIBRARY_PATH=/tmp/python-build.20240325124651.73089/Python…

I’ve quite literally never seen it download a pre-compiled Python - I didn’t actually know it had that functionality, and have been using it for probably a decade.

Ditto. I had no idea that it ever looked for a pre-compiled version.

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

#159
post #110
post #61

Earlier quoted context omitted.

It's inherit problem for all languages based on some runtime. Java, PHP, Ruby, whatever have the same issue. And TBH it's not very major issue to start with. No other solution besides fixed OS (containers, nix) could solve this problem.

The link posted solved this problem without containers

Github issues for pyenv show a slightly opposite picture.

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

#160

I really love miniconda for managing python versions and deps myself.

Conda/Miniconda randomly breaks every few months or so when updating and I can't fix it. Idk why I stick with it, its been like this for years.
Post reply on HN