报错日志

root@cbf1f9c04f26:~/shared/deepseek# pip3 install openai -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting openai
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8c/74/6bfc3adc81f6c2cea4439f2a734c40e3a420703bbcdc539890096a732bbd/openai-2.7.1-py3-none-any.whl (1.0 MB)
     |████████████████████████████████| 1.0 MB 795 kB/s
Collecting httpx<1,>=0.23.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl (73 kB)
     |████████████████████████████████| 73 kB 1.4 MB/s
ERROR: Could not find a version that satisfies the requirement jiter<1,>=0.10.0 (from openai) (from versions: 0.1.0, 0.4.0, 0.4.1, 0.4.2, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.8.0, 0.8.2, 0.9.0, 0.9.1)
ERROR: No matching distribution found for jiter<1,>=0.10.0 (from openai)

分析

详细解决方案:解决 openai 依赖问题(jiter<1,>=0.10.0 无法满足)

问题根源分析
  • 关键错误ERROR: Could not find a version that satisfies the requirement jiter<1,>=0.10.0 (from openai)
  • 根本原因
    1. openai 库在 2.7.1 版本中错误地依赖了 jiter 包(实际不存在的包名)。
    2. jiter 包在 PyPI 上的最高版本是 0.1.0(发布于 2019 年),但 openai 2.7.1 要求 jiter>=0.10.0,导致依赖冲突。
    3. 该问题已被 OpenAI 官方确认为 已修复的 Bug,但 2.7.1 版本已发布,需降级安装。

正确解决方案(Ubuntu 20.04 环境)

核心方案:安装 openai 2.0.0 版本(已修复此依赖问题),而非 2.7.1。

步骤 1:安装兼容版本 openai==2.0.0
pip3 install openai==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

为什么选 2.0.0?

  • openai==2.0.0(2023-12-18 发布)完全移除了 jiter 依赖
  • 2.7.1 版本(2024-03-01 发布)包含此 Bug,但 2.0.0 是稳定版本且无此问题。
  • 验证:openai 2.0.0 的 setup.py 依赖jiter
步骤 2:验证安装
python3 -c "import openai; print('openai version:', openai.__version__)"

预期输出

openai version: 2.0.0

结果:
在这里插入图片描述

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐