ARTIFACTORY: pip install doesn’t work with pip 22.x

Ariel Kabov
2022-01-31 08:58

Why do I get an error when trying to download PyPI packages after I upgraded my PIP client?

The Pip client 22.0 was released on January 29th, 2022. This version changed the package used for HTTP parsing. As a result, this change generated errors when installing pip packages from private registries, including JFrog Artifactory.

We (JFrog) are aware of this issue and are already working on releasing a fix.

Update: Pip released version 22.0.2 with an automatic fallback to use html5lib in case the above error is encountered. While this resolves the pip install errors, it still first tries to use http.parser which fails, meaning there are unnecessary extra requests to your Artifactory instance. 

Future versions of Artifactory will contain a solution from our end to support the http.parser, you can follow the progress here.

Am I affected?

Until the fix is available, all Artifactory versions are affected when working with the new PIP client version.

If you are using pip version 22.0.0 or 22.0.1, you are affected and expected to encounter the following error when attempting to install a package via Artifactory:$ pip3 install map                                                                                                           

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Looking in indexes: http://user:****@artifactory.jfrog.io/artifactory/api/pypi/pypi-virtual/simple
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 165, in exc_logging_wrapper
    status = run_func(*args)

  File "/usr/local/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.

Mitigation Steps

1. Upgrade your pip client to version 22.0.2 which includes an automatic fallback to use html5lib.

2. Using pip 22.0.1 or above, follow one of the below methods to use the html5lib:

a. Set this environment variable: PIP_USE_DEPRECATED=html5lib

b. Use this flag in your install commands: --use-deprecated=html5lib

3. Alternatively, you can downgrade the pip client using one of the methods:

  • Downgrade to the latest pip version prior to the breaking change:
$ pip3 install --no-cache --upgrade pip==21.3.1 -i https://pypi.org/simple/Note. The downgrade command requires access to pypi.org, as you won't be able to downgrade by installing the package from Artifactory due to the HTML doctype mismatch issue.

  • If you don't have access to pypi.org, you can uninstall pip entirely and install the pip version that is bundled with your Python version:

$ python3 -m pip uninstall pip
$ python3 -m ensurepip