You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker构建Django应用时sentry-sdk版本冲突问题排查

Docker构建Django应用时sentry-sdk版本冲突问题

背景

我正在尝试使用Docker更新Django应用的Sentry日志功能。我的requirements.txt文件第213-214行仅包含以下内容:

213: sendgrid==6.7.0
214: sentry-sdk==1.30.0 

注:sendgrid6.7.0并不依赖sentry-sdk1.9.5,我扫描了其他包也未发现该依赖。

构建应用时出现版本冲突错误,提示同时请求了sentry-sdk==1.9.5和1.30.0,但requirements.txt和基础Docker镜像中均无1.9.5版本。我已尝试使用pip的--no-cache-dir参数、执行pip cache purge、先卸载sentry-sdk再重新安装等方法,均无法解决问题。

构建错误详情

checking if image already exist remotely xxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/xxxxxxxxxx
⛏️ Building image. It does not exist remotely xxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/xxxxxxxxxx
#0 building with "engine-builder" instance using kubernetes driver
#1 [internal] load build definition from Dockerfile.frontend
#1 transferring dockerfile:
#1 transferring dockerfile: 7.19kB done
#1 DONE 0.0s
#2 [internal] load metadata for ghcr.io/myuser/base-container-python-3.8-1:latest
#2 DONE 0.4s
#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s
#4 [internal] load build context
#4 DONE 0.0s
#5 [ 1/10] FROM ghcr.io/myuser/base-container-python-3.8-1:latest@sha256:xxxxxxxxxx
#5 resolve ghcr.io/myuser/base-container-python-3.8-1:latest@sha256:xxxxxxxxxx 0.0s done
#5 DONE 0.0s
#6 [auth] sharing credentials for xxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com
#6 DONE 0.0s
#7 importing cache manifest from xxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/xxxxxxxxxx:latest
#7 inferred cache manifest type: application/vnd.oci.image.index.v1+json done
#7 DONE 0.8s
#4 [internal] load build context
#4 transferring context: 173.60MB 4.2s
#4 ...
#5 [ 1/10] FROM ghcr.io/myuser/base-container-python-3.8-1:latest@sha256:xxxxxxxxx
...
#9 [ 3/10] COPY requirements.txt ./
#9 DONE 0.0s
#10 [ 4/10] RUN pip install -r requirements.txt --no-cache-dir
...
#10 21.15 Collecting sentry-sdk==1.9.5 (from -r requirements.txt (line 213))
#10 21.18   Downloading sentry_sdk-1.9.5-py2.py3-none-any.whl (157 kB)
#10 21.20      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.6/157.6 kB 18.8 MB/s eta 0:00:00
#10 21.20 Requirement already satisfied: sendgrid==6.7.0 in /usr/local/lib/python3.8/site-packages (from -r requirements.txt (line 214)) (6.7.0)
#10 21.24 ERROR: Cannot install sentry-sdk==1.30.0 and sentry-sdk==1.9.5 because these package versions have conflicting dependencies.
#10 21.24 
#10 21.24 The conflict is caused by:
#10 21.24     The user requested sentry-sdk==1.9.5
#10 21.24     The user requested sentry-sdk==1.30.0

已尝试的解决方法及结果

我修改了Dockerfile中的安装步骤,添加了卸载sentry-sdk的命令:

WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip uninstall -y sentry-sdk
RUN pip install -r requirements.txt --no-cache-dir 

执行后仍然报错:

#10 [ 4/11] RUN pip uninstall -y sentry-sdk
#10 0.786 Found existing installation: sentry-sdk 1.30.0
#10 0.807 Uninstalling sentry-sdk-1.30.0:
#10 0.859   Successfully uninstalled sentry-sdk-1.30.0
...
Collecting sentry-sdk==1.9.5 (from -r requirements.txt (line 213))
#11 20.18   Downloading sentry_sdk-1.9.5-py2.py3-none-any.whl (157 kB)
#11 20.19      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.6/157.6 kB 20.4 MB/s eta 0:00:00
#11 20.20 Requirement already satisfied: sendgrid==6.7.0 in /usr/local/lib/python3.8/site-packages (from -r requirements.txt (line 214)) (6.7.0)
#11 20.23 ERROR: Cannot install sentry-sdk==1.30.0 and sentry-sdk==1.9.5 because these package versions have conflicting dependencies.
#11 20.23 
#11 20.23 The conflict is caused by:
#11 20.23     The user requested sentry-sdk==1.9.5
#11 20.23     The user requested sentry-sdk==1.30.0

疑问

  1. sentry-sdk==1.9.5的来源是什么?
  2. 还有其他解决方法吗?

内容的提问来源于stack exchange,提问作者Chris B.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 16:54:53