pip-compile 在其日志记录处理程序上引发 AssertionError

pip-compile raising AssertionError on its logging handler

我有一个目前只安装 pip-tools 的 dockerfile

FROM python:3.9

RUN pip install --upgrade pip && \
    pip install pip-tools

COPY ./ /root/project

WORKDIR /root/project

ENTRYPOINT ["tail", "-f", "/dev/null"]

我使用以下命令在容器中构建并打开一个 shell:

docker build -t brunoapi_image .
docker run --rm -ti --name brunoapi_container --entrypoint bash brunoapi_image

然后,当我尝试在容器内 运行 pip-compile 时,我得到了这个非常奇怪的错误(完整回溯):

root@727f1f38f095:~/project# pip-compile
Traceback (most recent call last):
  File "/usr/local/bin/pip-compile", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/piptools/scripts/compile.py", line 342, in cli
    repository = PyPIRepository(pip_args, cache_dir=cache_dir)
  File "/usr/local/lib/python3.9/site-packages/piptools/repositories/pypi.py", line 106, in __init__
    self._setup_logging()
  File "/usr/local/lib/python3.9/site-packages/piptools/repositories/pypi.py", line 455, in _setup_logging
    assert isinstance(handler, logging.StreamHandler)
AssertionError

我不知道发生了什么,而且我以前从未见过这个错误。任何人都可以对此有所了解吗?

运行 在 macOS Monterey

这是一个错误,您可以使用以下方式降级:

pip install "pip<22"

https://github.com/jazzband/pip-tools/issues/1558

截至目前,通过以下方式升级pip-compile就足够了:

pip install --upgrade pip-tools

由于@SEDaradji 提到的错误已解决。

pip install --upgrade pip-tools

更新 pip-tools 是我修复它的方法