'pip-compile error using Anaconda - File "/opt/anaconda3/bin/pip-compile", line 8, in <module> sys.exit(cli())

My pip version is 22.0.4. I had the most recent version but had to downgrad because I noticed the same error mentioned here: https://github.com/jazzband/pip-tools/issues/1617)

When I try to run pip-compile to update the requirements.txt file but I keep seeing the below error:

(base) krs@me-user ds-airflow % pip-compile
WARNING:pip._internal.metadata.base:Ignoring invalid distribution -rllib3 (/opt/anaconda3/lib/python3.8/site-packages)
WARNING:pip._internal.metadata.base:Ignoring invalid distribution -otocore (/opt/anaconda3/lib/python3.8/site-packages)
WARNING:pip._internal.metadata.base:Ignoring invalid distribution -ix (/opt/anaconda3/lib/python3.8/site-packages)
WARNING:pip._internal.metadata.base:Ignoring invalid distribution - (/opt/anaconda3/lib/python3.8/site-packages)
Traceback (most recent call last):
  File "/opt/anaconda3/bin/pip-compile", line 8, in <module>
    sys.exit(cli())
  File "/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/anaconda3/lib/python3.8/site-packages/piptools/scripts/compile.py", line 313, in cli
    repository = PyPIRepository(pip_args, cache_dir=cache_dir)
  File "/opt/anaconda3/lib/python3.8/site-packages/piptools/repositories/pypi.py", line 93, in __init__
    self._setup_logging()
  File "/opt/anaconda3/lib/python3.8/site-packages/piptools/repositories/pypi.py", line 451, in _setup_logging
    assert isinstance(handler, logging.StreamHandler)
AssertionError

EDIT: I just tried running: pip-compile --upgrade

  File "/opt/anaconda3/bin/pip-compile", line 8, in <module>
    sys.exit(cli())
  File "/opt/anaconda3/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/opt/anaconda3/bin/python3', '/opt/anaconda3/lib/python3.8/site-packages/pep517/in_process/_in_process.py', 'get_requires_for_build_wheel', '/var/folders/2b/d94v_0s54rxfx2ylxg20xh5c0000gn/T/tmp2o517hrt']' returned non-zero exit status 1.

EDIT EDIT: I've run conda list '(pip|click)' and see the following, but my requirements.txt file has hundreds of packages:

# packages in environment at /opt/anaconda3:
#
# Name                    Version                   Build  Channel
click                     7.1.1                    pypi_0    pypi
click-default-group       1.2.2                    pypi_0    pypi
clickclick                20.10.2                  pypi_0    pypi
pip                       20.2.4                   pypi_0    pypi
pip-tools                 6.6.0                    pypi_0    pypi


Solution 1:[1]

The version combination of pip=20.2.4 and pip-tools=6.6.0 is not compatible. Either upgrade pip to >=21.2, or downgrade pip-tools to 5.5.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 merv