pip: pip3 list -o fails with TypeError: unorderable types: Version() > SetuptoolsVersion()

In case vendor packages of pip are unbundled but the vendored “packaging” in setuptool (pkg_resources) not, pip3 list -o fails with

Exception:
Traceback (most recent call last):
  File "/usr/lib64/python3.4/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/usr/lib64/python3.4/site-packages/pip/commands/list.py", line 95, in run
    self.run_outdated(options)
  File "/usr/lib64/python3.4/site-packages/pip/commands/list.py", line 107, in run_outdated
    if version > dist.parsed_version:
TypeError: unorderable types: Version() > SetuptoolsVersion()

I cannot find the origin of the problem. packaging is 15.3 as it is in setuptools-18.2 and pip-7.1.2.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 3
  • Comments: 32 (6 by maintainers)

Commits related to this issue

Most upvoted comments

As @Kami-no said, this is caused by the fact that the way some distros package pip is not supported and fragile. The way to fix this to install pip from PyPI. You can even do this to fix it:

pip install --ignore-installed pip

I recommend passing --user additionally.

Workaround for anyone experiencing this:

# pip3 install --force pip

To forcibly install the “real” version of pip from PiPy.

Final solution:

pip install --force pip==9.0.0
pip install -U pip

Suppose smth wrong with pip from distro (Kali Linux + virtualenv)

It’s not about pip version it’s about pip from disto. Force to download pip from pip by downgrading it (even any lesser release). Now the problem is solved (pip3 list -o) and you’re free to upgrade pip or any other package with pip.

That command, pip3 install --ignore-installed pip --user, broke pip3 for me

: pip3 list -o
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

I can confirm this is still a problem. I had all the latest versions, but:

$ pip3 list --outdated
Exception:
...
TypeError: '>' not supported between instances of 'Version' and 'SetuptoolsVersion'

But many thanks to @pradyunsg because this:

pip3 install --ignore-installed pip --user

Fixed it! ❤️

The same happens for me with 9.0.1. Solved with:

pip install --force pip==9.0.0

You can’t break the system pip by installing another version in your site package. However the pip’s main entrypoint changed in newer versions, and even when you use one of the /usr/bin/pip launcher, you’re user installed version will be used (that’s normal, that’s how the Python path work): hence the import error. You can use python -s -m pip to invoke the system version even if you have another user installed version (-s will disable the user site). Finally, you can use python -m site to find out the location of user site packages.

Linux mint 19 Tara Python 3.6.5 Pip 9.0.1

$ 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'**