Live data from Hacker News

Pyenv – lets you easily switch between multiple versions of Python

github.com

241–250 of 341 posts

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

#241

Earlier quoted context omitted.

For now most people would do well to stick to python.org installers for mac and windows. For linux, official repos are ideal. If you really, really can't (which is different than wanting to), ubuntu deadsnake and red hat epl are the best second plan, while already more finicky. If you use something more exotic, you chose hardship, and you will have to be up to the task. Anything else will come with bigger caveats tha…

Even on Macs, you can use MacPorts. They provide a lot of versions pre-compiled (and everything is BSD-solid).

Personally I only use MacPorts or Homebrew to install random smaller tools. It's easier to install Python, NodeJS, Postgres, etc binaries from the main website.

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

#242

Earlier quoted context omitted.

There isn't one. Python distribution and packaging is just fundamentally horribly broken. I think his point was that you shouldn't pretend to users that just switching to pyenv is the solution.

> Python distribution and packaging is just fundamentally horribly broken It's clearly not because most people successfully use it fine. The problem of distribution and packaging is often a matter of user expectations vs. the actual problem. The user expectations is that Python is a high level language and will run the same across different machines regardless of OS and Hardware. The actual problem is Python is a glu…

They use it fine by using Docker. So many major Python repos on GitHub come with a Dockerfile compared to, say, NodeJS. It's unfortunate, but having dealt with Python packages before, I don't blame them.

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

#243

Earlier quoted context omitted.

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.

> For a beginner trying to run someone else's Python project, it is free.

Its absolutely, by far, the highest friction alternative on Windows for anyone that doesn't use Docker for other purposes.

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

#244

Earlier quoted context omitted.

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.

> For a beginner trying to run someone else's Python project, it is free. Its absolutely, by far, the highest friction alternative on Windows for anyone that doesn't use Docker for other purposes.

Is it not just install and run? The alternative is installing Python, installing pip, etc.

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

#245
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…

Sometimes, an app or library developer wants to target multiple Linux distributions.

For example, I want my own Python apps to work equally well on Debian oldstable (which currently provides Python 3.9) and Arch Linux (currently on 3.11). That means that I’m going to choose the lowest common version (3.9) as the language level for my app or library.

And if I program against a 3.9 language level, I absolutely *refuse* to use any other interpreter than a 3.9 one at development time. (If I used a newer one, then my linter and type checker would helpfully give me false alarms all the time, unaware of the actual language level.)

Hence, I use pyenv and poetry to get exactly the interpreter for the language level I want, and to allow pylint and mypy to be perfectly aware of the language level I’m using at development time, allowing them to give me findings that actually make sense.

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

#246
post #12

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…

> it compiles python on your machine What is the alternative? Every solution that I know of on Linux requires you to build Python on the machine: asdf, official Python downloads, etc.

try pyoxidizer

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

#247

Earlier quoted context omitted.

If you’re lucky enough to be on a Linux system that uses apt some thankless soul maintains a repo called deadsnakes with all these binaries. Fabulous if you’re using any somewhat old version of Python in CI for instance. Yum based systems are SOL as far as I can tell. Build and host your own binary for that. Apk doesn’t have this either IIRC

If you are deploying to such an ancient OS, it's perhaps easier to have the whole OS packaged as a container or a VM and use that. It's not only different Python versions that might bite you.

What makes you think that GP’s comment is talking about older OSes?

My understanding of their comment is that they’re talking about getting older Python interpreters to run on more modern OSes, modern enough that they don’t carry the older Python as a system package anymore. Hence, deadsnakes.

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

#248

Earlier quoted context omitted.

I just hit it a few days ago. 3rd party script that I did not write. The dev has lost interest in it 3 years ago. It is written for 2.7.x (and it is a nontrivial amount of code). So my choices are some sort of pyenv thing (or one of them), or fix up the script myself so it runs on 3.12. I lucked out and someone else had already done the second thing. One project I worked on was 2.4.x. If they ever have to update that…

download python 2.7 and run it? no pyenv needed

2.7 has been EOL for five years. It doesn’t get security updates nor bug fixes.

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

#249
post #25

Earlier quoted context omitted.

Actually, it only builds it locally if it can't find a pre-packaged version for your system/arch. Admittedly that's most of the recent ones on a Mac, but there is a difference (I've been using pyenv for nearly ten years[1] now). The big advantage for me is that I can match whatever runtime and standard library a target has (and yes, that's needed more times than not, even in this new age of Docker). Additionally, you…

Currently going through this myself on a new mac I bought lol. Still haven't gotten anywhere. Oh well $ PYTHON_CONFIGURE_OPTS='--disable-ipv6 --enable-optimizations --with-lto' PYTHON_CFLAGS='-march=native -mtune=native' pyenv install 3.12.2 python-build: use openssl@3 from homebrew python-build: use readline from homebrew Downloading Python-3.12.2.tar.xz... -> https://www.python.org/ftp/python/3.12.2/Python-3.12.2.t…

Actually, I installed rye and got everything working. There goes any usage of pyenv going forward lol.

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

#250

Earlier quoted context omitted.

> For a beginner trying to run someone else's Python project, it is free. Its absolutely, by far, the highest friction alternative on Windows for anyone that doesn't use Docker for other purposes.

Is it not just install and run? The alternative is installing Python, installing pip, etc.

Installing python with the python.org installer installs the entirety of Python and its standard library and tools, including pip, venv, etc., and the py launcher which supports selecting from multiple python versions. Linux distros may split this up into different packages, but on Windows (or Mac, afaik, though the py launcher is a Windows-only feature) using the official installers is one-stop shopping.

And, no, docker isn't just install and run on Windows. Before Docker made a heavy push for paid Docker Desktop for even personal use, it was close to that.

But now the way to get a free usable docker command line is to install WSL and a Linux environment, install docker there, and then invoke docker via wsl. (Which, of course, you will not find via Docker’s own information, which will try to sell you a paid subscription.)

Post reply on HN