Pragmatism in the real world

Reinstall pipx apps after Homebrew Python upgrade

I install Python apps on my Mac using pipx like this:

pipx install rst2pdf

This will then install rst2pdf into its own isolated environment so that its dependencies do not affect and are not affected by any other Python app I have installed.

Internally, it creates a venv at /.local/pipx/venvs/rst2pdf with symlinks to the currently installed python in the bin directory:

lrwxrwxr-x@  1 rob  staff     10 24 May  2023 python -> python3.11
lrwxrwxr-x@  1 rob  staff     10 24 May  2023 python3 -> python3.11
lrwxrwxr-x@  1 rob  staff     96 24 May  2023 python3.11 -> /opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/bin/python3.11

All is good.

However, when the Homebrew version of Python is updated, the old version is removed.

Running rst2pdf now fails with “cannot execute: required file not found” as the linked python no longer exists.

It’s easy enough to fix when you work out what’s happened:

pipx reinstall-all

I wish this situation was handled a little bit better though.

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *