Live data from Hacker News

Pyenv – lets you easily switch between multiple versions of Python

github.com

281–290 of 341 posts

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

#281

I really find it quite astounding just how much absolute nonsense python programmers are willing to put up with. Needing more than one, MAYBE two versions of your language installed is insanity. If I build a Python widget and send it to my non-programmer coworker, there is exactly zero chance it will work until I walk over and manually set up the correct language. Instead I use a language that natively compiles to an…

I've been programming in Python for years and I agree: Python isn't really for consumers. But hey it is used for LLMs that can generate React apps, so there's that.

I am only half-kidding. But it appears the industry as a whole is concentrating effort on fewer languages and Python is one of them. If I want to distribute my app - I write it in React, but I still often use python in the process: prototyping, asking GPT to rewrite X from python to typescript, making mock servers for tests / preparing data for unit tests.

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

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

> But I have never encountered a dependency resolution issue or been forced to use poetry. What am I doing wrong?

Not using python on a system without the necessary build tools while trying to use dependencies with native code that don't have binaries built for your combination of python version and platform?

This used to be a huge problem with Python on Windows, as things that weren't pure Python would very often not have binary packages or have them for a narrow set of python versions, often not the same set as other dependencies. (Not just a windows problem, but it was definitely big on windows.)

Tooling and practices have advanced so that more packages are automatically built against a wider set of targets, so the problem is a lot smaller than it used to be.

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

#283

Earlier quoted context omitted.

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, do…

I tried it just now on my spare Win10 desktop, and it went like this:

1. Download and install Docker desktop for Windows

2. Restart Windows (guess you don't have to do this with just Python)

3. Run Docker Desktop

4. Say "no" to signing into a Docker account

5. Wait for engine to start, which took a few minutes the first time, a bit annoying

6. Pull and run an image (I tried nginx)

It was weird being asked to log in, but the "no" button was pretty clear. I didn't feel like I was forced to use WSL to avoid paying; maybe they've backtracked from something. Unity was far more convincing that I had to pay.

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

#284
post #219

Earlier quoted context omitted.

Not with the macOS Python from the Xcode developer tools: > Error: This build of python cannot create venvs without using symlinks

Don't use that one

— Doctor, it hurts when I raise may arm.

— Then don’t raise your arm.

Like I said in the original comment you replied to and are now ignoring:

> That’s not a practical solution. Sometimes you don’t have a choice, as demonstrated above. By that logic one could say “don’t change anything about your system and you don’t even need virtual environments”. Which is somewhat true, but also profoundly unhelpful.

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

#285
post #135

Earlier quoted context omitted.

But how do I get a .venv with a new/different version of Python in your setup? And how do I add some kind of Python version requirement in my project?

python3.xx -m venv .

And pyenv gives you python 3.xx rather than 3.xy...

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

#286

I really find it quite astounding just how much absolute nonsense python programmers are willing to put up with. Needing more than one, MAYBE two versions of your language installed is insanity. If I build a Python widget and send it to my non-programmer coworker, there is exactly zero chance it will work until I walk over and manually set up the correct language. Instead I use a language that natively compiles to an…

You're just using the wrong tool for the job.

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

#287

Earlier quoted context omitted.

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.

I modified my bash prompt to detect and auto-activate Python environments, and show if one is currently active. Haven’t thought about activate in years. It’s great.

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

#288
Why not just use a tool like asdf (https://asdf-vm.com/) or mise (https://mise.jdx.dev/)?

These tools have the advantage of not being multi-taskers and can manage version for all your tools. You wouldn’t need pyenv and npm and rvm and…

We’ve even started committing the .mise.toml files for projects to our repos. That way, since we work on multiple projects that may need multiple versions of the same tool, it’s handled and documented.

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

#289

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.

Even at that, there are edge cases like when a python package like Tensorflow uses a instruction set that is not available on a Arm machine.

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

#290
post #267

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

That's exactly why I don't really on that for Ubuntu though. It's a single point of failure, when I can just use `asdf` to install Python and easily switch between it, automatically if setup correctly on projects.

I use asdf on my local machine, stuff like deadsnakes is for when you need your CI to use VaguelyOldButStillSupported Python version and don’t want to either compile Python from source or host your own binary
Post reply on HN