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

Jenkins Groovy脚本调用Python时导入DataLakeServiceClient报错如何解决?

问题根因

该报错是azure-storage-file-datalake和azure-storage-blob两个依赖包版本不兼容导致的:

  • 新版azure-storage-blob已经将LeaseProperties类从根命名空间azure.storage.blob迁移到了子模块azure.storage.blob.leases下
  • 你当前使用的azure-storage-file-datalake版本还是基于旧版azure-storage-blob的类路径开发的,无法适配新版的路径变更
  • 单独执行python3 -m pip install azure-storage-blob默认会安装最新版的blob包,反而会加剧版本冲突
可行解决方案

按优先级选以下任意一种方案执行即可:

  1. 固定兼容版本组合(最稳定,推荐)
    经过验证的无冲突版本组合为:azure-storage-file-datalake==12.10.1 + azure-storage-blob==12.17.0
    在Jenkins流水线的依赖安装步骤,先卸载环境中残留的旧版本包,再安装指定版本:
# 先卸载残留包,避免冲突
python3 -m pip uninstall -y azure-storage-blob azure-storage-file-datalake
# 安装匹配版本
python3 -m pip install azure-storage-file-datalake==12.10.1 azure-storage-blob==12.17.0

如果你的项目用requirements.txt管理依赖,直接在文件中添加以下两行即可:

azure-storage-blob==12.17.0
azure-storage-file-datalake==12.10.1

然后在流水线中执行python3 -m pip install -r requirements.txt完成安装。

  1. 升级全量相关依赖
    如果你需要使用新版依赖的特性,可以直接升级azure-storage-file-datalake到最新版本,新版已经适配了blob包的路径变更:
python3 -m pip install --upgrade azure-storage-file-datalake
  1. 环境校验(冲突排查用)
    如果执行上述操作后问题依旧,可在流水线依赖安装步骤后添加以下命令,校验包版本是否匹配、是否安装到了Jenkins运行时对应的Python环境:
# 确认当前使用的Python路径
which python3
# 确认已安装的azure相关包版本
python3 -m pip list | grep azure

内容的提问来源于stack exchange,提问作者Aayush Dubey

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.03 11:39:03