Skip to content

【Bug: 依赖冲突】项目安装时 f2 和 bilibili-api-python 导致 httpx 版本循环冲突 #2

@ZZ0YY

Description

@ZZ0YY

1. 问题描述

在尝试安装 requirements.txt 中的依赖时,pip 解析器陷入了循环冲突,无法同时满足 f2bilibili-api-python 库对 httpx 版本的要求。

2. 重现步骤

  1. 克隆项目代码。
  2. 确保 requirements.txt 中存在以下冲突依赖的版本(或者按照项目默认配置)。
  3. 在虚拟环境中运行安装命令:
    pip install -r requirements.txt

3. 错误日志(核心冲突部分)

这是导致安装失败的依赖冲突日志:

ERROR: Cannot install f2==0.0.1.6 and httpx==0.24.1 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested httpx==0.24.1
    f2 0.0.1.6 depends on httpx==0.27.0

ERROR: ResolutionImpossible: for help visit [https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts](https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts)
  1. 冲突分析
    冲突的根本原因是两个依赖包对核心库 httpx 的版本要求完全不兼容:
    | 库名 | 冲突版本 | 对 httpx 的版本要求 | 结果 |
    |---|---|---|---|
    | f2 | 0.0.1.6 | 严格要求 httpx==0.27.0 | 只能接受 0.27.0 |
    | bilibili-api-python | (在 requirements.txt 中是 16.1.1) | 要求 httpx~=0.24.1 (即 \ge 0.24.1 且 < 0.25.0) | 无法接受 0.27.0 |
  2. 已尝试的解决方案及结果
    为了解决冲突,我们尝试了以下方案,但均未成功找到一个统一的 httpx 版本:
    | 尝试方案 | 结果 |
    |---|---|
    | 1. 固定 httpx 到 0.24.1 (兼容 bilibili-api-python) | 导致 f2==0.0.1.6 报错,因为它严格要求 httpx==0.27.0。 |
    | 2. 固定 httpx 到 0.27.0 (兼容 f2) 并尝试安装最新版 bilibili-api-python | pip 仍因 bilibili-api-python 旧版本的依赖限制而失败,显示冲突。 |

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions