[WORKAROUND] Unable to update brewblox due to 'HTML doctype' error

When attempting to perform brewblox-ctl update, I’m encountering an ‘HTML doctype’ error:

pi@brewpi:~/brewblox $ brewblox-ctl update
INFO       Updating brewblox-ctl...
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pip in ./.venv/lib/python3.9/site-packages (22.0)
ERROR: Exception:
Traceback (most recent call last):
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 165, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 339, in run
    requirement_set = resolver.resolve(
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 94, in resolve
    result = self._result = resolver.resolve(
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
    return bool(self._sequence)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
    return any(self)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 90, in _iter_built_with_inserted
    for version, func in infos:
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 294, in iter_index_candidate_infos
    result = self._finder.find_best_candidate(
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/index/package_finder.py", line 868, in find_best_candidate
    candidates = self.find_all_candidates(project_name)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/index/package_finder.py", line 809, in find_all_candidates
    page_candidates = list(page_candidates_it)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/index/sources.py", line 134, in page_candidates
    yield from self._candidates_from_page(self._link)
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/index/package_finder.py", line 773, in process_project_url
    page_links = list(parse_links(html_page, self._use_deprecated_html5lib))
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/index/collector.py", line 310, in wrapper_wrapper
    return list(fn(page, use_deprecated_html5lib))
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/index/collector.py", line 350, in parse_links
    parser.feed(page.content.decode(encoding))
  File "/usr/lib/python3.9/html/parser.py", line 110, in feed
    self.goahead(0)
  File "/usr/lib/python3.9/html/parser.py", line 178, in goahead
    k = self.parse_html_declaration(i)
  File "/usr/lib/python3.9/html/parser.py", line 269, in parse_html_declaration
    self.handle_decl(rawdata[i+2:gtpos])
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/index/collector.py", line 405, in handle_decl
    self._raise_error()
  File "/home/pi/brewblox/.venv/lib/python3.9/site-packages/pip/_internal/index/collector.py", line 426, in _raise_error
    raise ValueError(
ValueError: HTML doctype missing or incorrect. Expected <!DOCTYPE html>.

If you believe this error to be incorrect, try passing the command line option --use-deprecated=html5lib and please leave a comment on the pip issue at https://github.com/pypa/pip/issues/10825.
Command 'python3 -m pip install --upgrade --no-cache-dir pip' returned non-zero exit status 2.

Workaround

This issue may be due to a compatibility issue between the latest pip version and piwheels.org. Presumably, it will get resolved at some point, but a workaround for the time being is to edit your /etc/pip.conf file to comment out the extra index URL:

[global]
# extra-index-url=https://www.piwheels.org/simple

Note that this workaround may lead to future issues when updating brewblox. If the cryptography package is ever out of date it will have to be built locally with the rust compiler. Other packages may also run into issues due to build dependencies not being installed locally.

3 Likes