"pip3 list --outdated" raises TypeError

Bug #1579181 reported by Paul Natsuo Kishimoto
70
This bug affects 15 people
Affects Status Importance Assigned to Milestone
pip
Fix Released
Unknown
python-pip (Debian)
Fix Released
Unknown
python-pip (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Observed:

$ pip3 list --outdated
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/list.py", line 118, in run
    self.run_outdated(options)
  File "/usr/lib/python3/dist-packages/pip/commands/list.py", line 128, in run_outdated
    if latest_version > dist.parsed_version:
TypeError: unorderable types: Version() > SetuptoolsVersion()

Expected: a list of outdated packages is displayed.

This particular exception appears to be discussed upstream at:
https://github.com/pypa/pip/issues/3057

where an upstream dev says, quote, "I don't think there's anything we can reasonably do here, you're running a patched or unsupported version of pip. You should file a bug with whomever gave you your copy of pip and ask them to stop patching it."

$ lsb_release -rd && apt-cache policy python3-pip
Description: Ubuntu 16.04 LTS
Release: 16.04
python3-pip:
  Installed: 8.1.1-2
  Candidate: 8.1.1-2
  Version table:
 *** 8.1.1-2 500
        500 http://mirrors.mit.edu/ubuntu xenial/universe amd64 Packages
        500 http://mirrors.mit.edu/ubuntu xenial/universe i386 Packages
        100 /var/lib/dpkg/status

Revision history for this message
Paul Natsuo Kishimoto (khaeru) wrote :

A workaround is:

$ pip3 install --user --no-deps pip
Collecting pip
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
    100% |████████████████████████████████| 1.2MB 612kB/s
Installing collected packages: pip
Successfully installed pip-8.1.1

…(i.e. exactly the same version of pip) and ensure ~/.local/bin is in my $PATH.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-pip (Ubuntu):
status: New → Confirmed
Revision history for this message
Edwin Khoo (edwinksl) wrote :

If you are using virtualenv, then forcing a reinstallation of pip is a workaround:

pip install -U --force-reinstall pip

tags: added: artful
Changed in python-pip (Debian):
status: Unknown → New
Revision history for this message
Paulo Marcel Coelho Aragão (marcelpaulo) wrote :

The affected package should be python3-pip and not python-pip, since 'pip list --outdated' doesn't provoke the exception, but 'pip3 list --outdated' does.

Revision history for this message
Kent Ross (mumbleskates) wrote :

This is occurring for me with python3.6-dev==3.6.4-4 amd64 from bionic/main. Forcing a reinstall of the system's python3.6 pip package fixes it, but this is pretty lousy default behavior.

Revision history for this message
Kent Ross (mumbleskates) wrote :

I suppose I should clarify: the system pip package is python3-pip==9.0.1-2 amd64 from bionic/universe

Revision history for this message
Ömer Fadıl USTA (omerusta) wrote :

With latest pip this issue solved. On the other hand you have to patch makepip3.py file (which creates /usr/bin/pip3 )

Revision history for this message
Ömer Fadıl USTA (omerusta) wrote :

I mean that patch for python3-pip package packagers . If you upgrade pip with pip (with sudo ) you need to edit your /usr/bin/pip3 file with this :

#!/usr/bin/python3
# GENERATED BY DEBIAN

import sys

# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
from pip._internal import main as _main
if __name__ == '__main__':
    sys.exit(_main())

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "patch for after updating pip via pip with sudo" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Laurent Bonnaud (laurent-bonnaud) wrote :

The problem still exists in Ubuntu 19.04/disco with a slightly different error message:

$ pip3 list --outdated
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 138, in run
    packages = self.get_outdated(packages, options)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 149, in get_outdated
    dist for dist in self.iter_packages_latest_infos(packages, options)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 150, in <listcomp>
    if dist.latest_version > dist.parsed_version
TypeError: '>' not supported between instances of 'Version' and 'Version'

tags: added: disco
Revision history for this message
Ari (ari-reads) wrote :

@Laurent were you able to fix it? same issue in my 19.04 install.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

another report of this in Debian (not yet merged): https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=912379

tags: added: bionic
Revision history for this message
Thomas Dreibholz (dreibh) wrote :

The problem still exists in the current Ubuntu Bionic (October 24, 2019):

dreibh@kringsjaa:~$ pip3 list --outdated
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/list.py", line 157, in run
    packages = self.get_outdated(packages, options)
  File "/usr/lib/python3/dist-packages/pip/commands/list.py", line 168, in get_outdated
    dist for dist in self.iter_packages_latest_infos(packages, options)
  File "/usr/lib/python3/dist-packages/pip/commands/list.py", line 169, in <listcomp>
    if dist.latest_version > dist.parsed_version
TypeError: '>' not supported between instances of 'Version' and 'Version'
dreibh@kringsjaa:~$ apt-show-versions | grep python3-pip
python3-pip:all/bionic-updates 9.0.1-2.3~ubuntu1.18.04.1 uptodate
dreibh@kringsjaa:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic

Since finding outdated packages is security-relevant, I would consider this bug being security-relevant as well.

tags: added: eoan
Revision history for this message
wavesailor (wavesailor) wrote :

Does anyone have a workaround for this issue until it gets resolved?

Revision history for this message
wavesailor (wavesailor) wrote :

I think I found a solution but not sure if it's the "right" thing to do so maybe experts can comment?

You need to modify the pip file: sudo vim /usr/bin/pip3

The original code is:

from pip import main
if __name__ == '__main__':
    sys.exit(main())

Need to change to:

from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__._main())

Then run this: sudo pip3 install pip --upgrade

Then you can run:
sudo pip3 list --outdated

Changed in python-pip (Debian):
status: New → Fix Released
Changed in python-pip (Debian):
status: Fix Released → New
Changed in python-pip (Debian):
status: New → Unknown
Changed in python-pip (Debian):
status: Unknown → Confirmed
tags: added: focal
Changed in python-pip (Debian):
status: Confirmed → Fix Released
Revision history for this message
Scott Kitterman (kitterman) wrote :

The fix for this was included in 20.0.2-4 imported from Debian.

 python-pip | 20.0.2-5ubuntu1 | focal/universe | source
 python-pip | 20.0.2-5ubuntu1 | groovy/universe | source

Changed in python-pip (Ubuntu):
status: Confirmed → Fix Released
Changed in pip:
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.