8

Suggestions please, thanks :)

pip list --outdated --format=freeze

Gives the following error:

ERROR: Exception:
Traceback (most recent call last):
 File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 223, in _main
 status = self.run(options, args)
 File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 175, in run
 packages = self.get_outdated(packages, options)
 File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 184, in get_outdated
 return [
 File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 184, in <listcomp>
 return [
 File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 237, in iter_packages_latest_infos
 for dist in map_multithread(latest_info, packages):
 File "/usr/lib/python3.9/multiprocessing/pool.py", line 870, in next
 raise value
 File "/usr/lib/python3.9/multiprocessing/pool.py", line 125, in worker
 result = (True, func(*args, **kwds))
 File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 214, in latest_info
 all_candidates = finder.find_all_candidates(dist.key)
 File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 825, in find_all_candidates
 package_links = self.process_project_url(
 File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 793, in process_project_url
 page_links = list(parse_links(html_page))
 File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 324, in wrapper_wrapper
 return list(fn(page))
 File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 335, in parse_links
 document = html5lib.parse(
 File "/usr/share/python-wheels/html5lib-1.1-py2.py3-none-any.whl/html5lib/html5parser.py", line 44, in parse
 tb = treebuilders.getTreeBuilder(treebuilder)
 File "/usr/share/python-wheels/html5lib-1.1-py2.py3-none-any.whl/html5lib/treebuilders/__init__.py", line 85, in getTreeBuilder
 return etree.getETreeModule(implementation, **kwargs).TreeBuilder
AttributeError: module 'html5lib.treebuilders.etree' has no attribute 'getETreeModule'
asked Sep 30, 2021 at 10:13
1
  • Did this issue occur after using this as a part of updating everything? That can break things, so reinstall pip. There is a very good answer below. Commented Dec 21, 2021 at 12:23

3 Answers 3

10

I solved this problem updating pip, i updated from pip 20.3.4 to 21.3 so just type:

pip install pip -U

Seems like there is some bug in pip itself.

Screenshot of the resolution of the problem

answered Oct 15, 2021 at 12:03
Sign up to request clarification or add additional context in comments.

1 Comment

This is the one and should be marked as the best answer. Should have thought of it myself. Scary error had me do a Googling.
2

I've done some analysis of this bug in in the Debian bugtracker.

It appears to be a race-condition triggered by the way Debian was packaging pip until recently. Dependencies were zipimported from wheels instead of vendored in the source tree, as upstream does.

This should already be resolved in Debian >= 12 (bookworm) and Ubuntu >= 22.04 (jammy).

An updated for pip in Debian 11 (bullseye) is in progress.

answered Mar 7, 2022 at 15:37

Comments

-1

Not a fix, but a solution of sorts:

I 'fixed' this by updating every package.

for f in `pip list | tail -n +3 | cut -d' ' -f1`; do
 pip install --update "$f";
done

I found OP's problem while logged-in as root and immediately after upgrading to Debian 11; dunno if that's significant.

answered Oct 4, 2021 at 13:18

3 Comments

This solution is like killing flies with a shotgun. Check my answer.
pip3 and --upgrade were what I needed.
This solution will work but is overengineered. The issue is one of pips dependencies, so you just want to fix that by updating/reinstalling Pip and its dependencies. Also, the issue in the OP probably was from trying to update everything, which breaks things. After updating everything, make sure pip works.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.