new method for updating python packages

There is a new version of Python’s pip, version 23. And because there’s a new version, there’s an important change in how to update Python packages. The new method (for Linux and macOS) is:

pip list --outdated --format=json | jq -r '.[] | "\(.name)==\(.latest_version)"' | xargs -n1 pip install -U

The big change is with --format=json. Before version 23 it was --format=freeze. Because the output is in JSON, there is a new utility in the pipeline as well, jq, the commandline JSON processor. If you’re curious, the manpage for jq is extensive.