Pip 22.3, list: List format 'freeze' can not be used with the --outdated option?

$ pip3 list --outdated --format=freeze
ERROR: List format 'freeze' can not be used with the --outdated option.

Doc says otherwise – pip list - pip documentation v22.3

What would be the equivalent of pip3 list --outdated --format=freeze in pip 22.3 and newer?

1 Like

A PR for a doc update would be welcomed.

From the changelog

Remove the ability to use pip list --outdated in combination with --format=freeze. (#9789)

this change was made in issue 9789. In that issue, I provide an alternative:

Actually, if you want the output @matrixise expects, the following gives it:

> py -m pip list --outdated --format=json | jq -r '.[] | .name+\"=\"+.latest_version'
idna=3.1
setuptools=54.2.0
urllib3=1.26.4

(excuse Powershell quoting rules, for Unix probably just omit the backslashes).

(But note that as per the discussion in the issue, this does not provide a list of requirements that will necessarily “upgrade everything” the way you would expect. See the issue for details).

3 Likes

So on mac, this works:

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

The same works for me on FreeBSD.

Omission works for me:

% python -m pip list --outdated --format=json | jq -r '.[] | .name+"="+.latest_version'
GDAL=3.6.1
pygraphviz=1.10
PyStemmer=2.2.0
scikit-sparse=0.4.8
SciPy=1.9.3
% python --version
Python 3.9.16
% pkg info -x jq
jq-1.6
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #27 main-n259662-ebdf27b6f367-dirty: Sun Dec 11 11:31:52 GMT 2022     grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1400074 1400074
% python3 -m pip list --outdated --format=json | jq -r '.[] | "\(.name)==\(.latest_version)"' | xargs -n1 pip3 install -U
Defaulting to user installation because normal site-packages is not writeable
Collecting GDAL==3.6.1
  Using cached GDAL-3.6.1.tar.gz (757 kB)
…
× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
% python -m pip list --outdated --format=json | jq -r '.[] | .name+"="+.latest_version'
GDAL=3.6.1
pygraphviz=1.10
PyStemmer=2.2.0
scikit-sparse=0.4.8
SciPy=1.9.3
% echo $SHELL
/bin/tcsh
% echo $0
/bin/tcsh
% 

(Upgrade errors are not a concern, here. Explanatory notes appeared, on screen. Nice.)

This suppresses the error message that occurs when no packages need to be updated. Tested on Ubuntu, should work everywhere that bash is provided … except maybe Mac, no idea about that OS:

nice python3 -m pip list --outdated --format=json | \
      jq -r '.[] | "\(.name)==\(.latest_version)"' | \
      xargs --no-run-if-empty -n1 pip3 install -U