Weeknotes 2021 Week 5

Just a quick one this week, we have a family birthday this weekend. 🎉

How should you install Python?

Justin Mayer put out a post this week on why Homebrew’s Python isn’t for you. This led to a good discussion on Twitter sparked by Simon Willison.

Homebrew’s Python is not for you. It exists to serve Homebrew, or more accurately, Homebrew’s other formulae. The primary purpose of Homebrew’s Python formula is to enable other Python-dependent Homebrew packages to work. If installing Homebrew’s Python allows you to run the occasional Python script or access the REPL, that’s a nice side benefit, but anything beyond that — including developing software with Python — is squarely out-of-scope.

Justin mentioned both macOS’s system Python and the apt installed (half-broken) distribution you get on Ubuntu as suffering the same problem. (I’ll let you find the links there, I’m partying 💃)

macOS’s system Python is there so that other things know there’s a particular Python in a particular place, and can safely use it. Break that and you’re in trouble.

So, what are you to do?

My take is that if you’re on macOS, and you just want a single version, get the official download from python.org. Running the installer is relatively painless (just click the buttons) and you're done: you have your very own Python that no-one is going to mess with behind your back.

If you need multiple versions of Python (because you’re a developer say) use pyenv. But for heaven’s sake, use the Basic GitHub checkout installation method, and not brew, or you’re back in the mix.

On Windows, if you just want one Python version, then get it from the Store. It couldn’t be easier. If you want multiple versions, then get the download from python.org. It comes with the awesome py launcher that lets you select your python version, much like pyenv.

On Ubuntu, which I only use in a server context, I install pyenv as part of my base-box setup, that’ll be part of Button (soon 🥳), so I just use that. Looking at the downloads on python.org it looks like you’d have to build from source (and I think I heard Mariusz say something along that lines testing the 3.10 alphas recently) so I’d say pyenv is probably the way to go.

I think lots of folks use pyenv. It’s awesome.

Justin mentioned asdf, which does node and Ruby too (and maybe others). I’m already using nondenv and rbenv and swiftenv, which are all variations on a theme, so I’m not really in the market to change. (But I’ll put it on the backlog to check out at some point.)

For me, the reason to prefer the official download (or the Store on Windows) is the effort of setting up these extra helpers. For many (most?) real-world users managing multiple Pythons just isn’t necessary. It’s not something I’d recommend as a first step. (As Will says, if you’re on Linux, you signed up for this, so it’s not an issue there. 😃)