我如何解释这个 python 依赖关系树?

How do I interpret this python dependency tree?

我们正在使用 conda 维护 python 环境,我想了解为什么 google-cloud-bigquery==1.22.0正在安装,最新可用版本 https://pypi.org/project/google-cloud-bigquery/2.16.1/ and the latest vaailable version on conda-forge (https://anaconda.org/conda-forge/google-cloud-bigquery) 为 2.15.0

这是构建我们的 conda 环境的 Dockerfile:

FROM debian:stretch-slim

RUN apt-get update && apt-get install curl gnupg -y && rm -rf /var/lib/apt/lists/*

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg && \
        install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg && \
        gpg --keyring /usr/share/keyrings/conda-archive-keyring.gpg --no-default-keyring \
        --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806 && \
        echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" \
        > /etc/apt/sources.list.d/conda.list

WORKDIR /tmp
RUN MINICONDA_VERSION=4.9.2 && \
        CONDA_VERSION='4.9.*' && \
        CONDA_DIR=/opt/conda && \
        curl -O https://repo.anaconda.com/miniconda/Miniconda3-py37_${MINICONDA_VERSION}-Linux-x86_64.sh && \
        /bin/bash Miniconda3-py37_${MINICONDA_VERSION}-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
        rm Miniconda3-py37_${MINICONDA_VERSION}-Linux-x86_64.sh && \
        $CONDA_DIR/bin/conda config --system --set auto_update_conda false && \
        $CONDA_DIR/bin/conda config --system --set show_channel_urls true && \
        $CONDA_DIR/bin/conda config --system --remove channels defaults && \
        $CONDA_DIR/bin/conda config --system --add channels main && \
        $CONDA_DIR/bin/conda config --system --set env_prompt '({name}) ' && \
        $CONDA_DIR/bin/conda config --system --append envs_dirs /opt/conda/envs/ && \
        $CONDA_DIR/bin/conda config --system --append pkgs_dirs /opt/conda/pkgs/ && \
        $CONDA_DIR/bin/conda update --quiet --yes --all conda="${CONDA_VERSION}" && \
        $CONDA_DIR/bin/conda config --system --append channels conda-forge  && \
        $CONDA_DIR/bin/conda create -n py3 python=3.8

RUN bash -c "source /opt/conda/bin/activate /opt/conda/envs/py3 && conda install \
                invoke \
                apache-beam \
                sh \
                pytest \
                pytest-xdist \
                ipython \
                behave \
                black \
                pylint \
                flake8 \
                jinja2 \
                tenacity \
                responses \
                tqdm \
                google-api-python-client \
                google-auth-oauthlib \
                google-cloud-monitoring \
                google-cloud-bigquery \
                google-cloud-storage \
                google-cloud-pubsub \
                google-cloud-secret-manager \
                ipdb \
                rope \
                pipdeptree"

我使用 docker build . -t conda-env 构建它,然后在容器内使用 pipdeptree 为我提供 google-cloud-bigquery:

的依赖树
docker run \
  --rm \
  --entrypoint bash \
  conda-env \
  -c "source /opt/conda/bin/activate /opt/conda/envs/py3 && pipdeptree --packages google-cloud-bigquery"

这给了我这个:

google-cloud-bigquery==1.22.0
  - google-cloud-core [required: >=1.0.3,<2.0dev, installed: 1.6.0]
    - google-api-core [required: >=1.21.0,<2.0.0dev, installed: 1.25.1]
      - google-auth [required: >=1.21.1,<2.0dev, installed: 1.28.1]
        - cachetools [required: >=2.0.0,<5.0, installed: 4.2.1]
        - pyasn1-modules [required: >=0.2.1, installed: 0.2.8]
          - pyasn1 [required: >=0.4.6,<0.5.0, installed: 0.4.8]
        - rsa [required: >=3.1.4,<5, installed: 4.7.2]
          - pyasn1 [required: >=0.1.3, installed: 0.4.8]
        - setuptools [required: >=40.3.0, installed: 52.0.0.post20210125]
        - six [required: >=1.9.0, installed: 1.15.0]
      - googleapis-common-protos [required: >=1.6.0,<2.0dev, installed: 1.53.0]
        - protobuf [required: >=3.12.0, installed: 3.14.0]
          - six [required: >=1.9, installed: 1.15.0]
      - protobuf [required: >=3.12.0, installed: 3.14.0]
        - six [required: >=1.9, installed: 1.15.0]
      - pytz [required: Any, installed: 2021.1]
      - requests [required: >=2.18.0,<3.0.0dev, installed: 2.25.1]
        - certifi [required: >=2017.4.17, installed: 2020.12.5]
        - chardet [required: >=3.0.2,<5, installed: 3.0.4]
        - idna [required: >=2.5,<3, installed: 2.10]
        - urllib3 [required: >=1.21.1,<1.27, installed: 1.26.4]
      - setuptools [required: >=40.3.0, installed: 52.0.0.post20210125]
      - six [required: >=1.13.0, installed: 1.15.0]
    - google-auth [required: >=1.24.0,<2.0dev, installed: 1.28.1]
      - cachetools [required: >=2.0.0,<5.0, installed: 4.2.1]
      - pyasn1-modules [required: >=0.2.1, installed: 0.2.8]
        - pyasn1 [required: >=0.4.6,<0.5.0, installed: 0.4.8]
      - rsa [required: >=3.1.4,<5, installed: 4.7.2]
        - pyasn1 [required: >=0.1.3, installed: 0.4.8]
      - setuptools [required: >=40.3.0, installed: 52.0.0.post20210125]
      - six [required: >=1.9.0, installed: 1.15.0]
    - six [required: >=1.12.0, installed: 1.15.0]
  - google-resumable-media [required: >=0.3.1,<0.6.0dev,!=0.4.0, installed: 0.5.1]
    - six [required: Any, installed: 1.15.0]
  - protobuf [required: >=3.6.0, installed: 3.14.0]
    - six [required: >=1.9, installed: 1.15.0]

我不得不举起手来承认我根本不知道该如何解释。例如,这样做:

google-cloud-bigquery==1.22.0
  - google-cloud-core [required: >=1.0.3,<2.0dev, installed: 1.6.0]

意味着 google-cloud-core 强制 google-cloud-bigquery 为“>=1.0.3,<2.0dev”或者它是否意味着 google- cloud-core 被其他东西强制为“>=1.0.3,<2.0dev”。我基本上不明白呈现给我的信息,所以我希望有人能启发我。更好的是,如果有人能告诉我如何安装更高版本的 google-cloud-bigquery 我将不胜感激,因为存在已知错误在 1.22.0.

先回答你的最后一个问题:

google-cloud-bigquery==1.22.0
  - google-cloud-core [required: >=1.0.3,<2.0dev, installed: 1.6.0]

表示google-cloud-bigquery安装了1.22.0版本,这要求google-cloud-core安装的版本介于1.0.3和2.0之间,并且您安装了1.6.0版本.

要检查 google-cloud-bigquery 的约束 - 您可能正在尝试这样做,请添加 --reverse 标志,如下所示:pipdeptree --reverse --packages google-cloud-bigquery。但是输出没有用,因为“你看错了树的一边”:

Warning!!! Possibly conflicting dependencies found:
* pylint==2.7.4
 - astroid [required: >=2.5.2,<2.7, installed: 2.5]
* flake8==3.9.0
 - pycodestyle [required: >=2.7.0,<2.8.0, installed: 2.6.0]
 - pyflakes [required: >=2.3.0,<2.4.0, installed: 2.2.0]
------------------------------------------------------------------------
google-cloud-bigquery==1.22.0

因此要查看实际克制,运行 pipdeptree --reverse 并寻找 google-cloud-bigquery。然后你会发现,1.26.4 版本中的 urllib3 约束 requests 到 2.25.1 版本,哪些约束 google-api-core 到 1.25.1,哪些约束 google-cloud-core 到 1.6 .0,将 google-cloud-bigquery 约束为 1.22.0.

如果我不得不猜测,我会说其中一个提到的软件包已经安装在它们各自的版本中(编辑:甚至在您安装特定软件包之前),这导致了您所看到的.

我 运行 pip install google-cloud-bigquery --upgrade 在你的构建之上,它工作得很好,所以你可以 运行 最后或者在安装你的特定东西之前升级所有包(我个人建议,更新你的基础总是一个好主意。话虽这么说,如果你自己的约束“太旧”,那是行不通的,你应该在安装了特定的之后回退到升级东西)。