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

调用BigQuery查询结果to_dataframe()时遇AttributeError错误求助

BigQuery to_dataframe() 报错AttributeError: 'ClientOptions' object has no attribute 'api_audience' 解决方案

问题根源

  • 依赖包版本冲突:google-cloud==0.34.0是老旧的整合式包,与你安装的google-cloud-bigquery==2.34.3等新拆分包不兼容,旧包会干扰新包中ClientOptions类的定义。
  • query.result()不依赖BigQuery Storage API的客户端配置,因此能正常运行;而to_dataframe()会触发Storage API初始化,进而暴露该冲突导致的属性缺失问题。

修复步骤

  1. 卸载冲突的老旧包
    执行命令:
    pip uninstall -y google-cloud
    
  2. 更新兼容的依赖版本
    运行以下命令升级相关Google Cloud包:
    pip install --upgrade google-cloud-bigquery google-cloud-bigquery-storage google-cloud-core google-cloud-storage
    
  3. 验证修复效果
    重新执行代码,检查to_dataframe()是否正常运行。

注意事项

  • 避免同时安装旧版整合包google-cloud和新版拆分服务包(如google-cloud-bigquery),二者底层模块会冲突,引发各类属性错误。
  • 后续仅安装所需的单个Google Cloud服务包,无需安装google-cloud这类整合包,以维持依赖兼容性。

内容的提问来源于stack exchange,提问作者Soumaya Dammak

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 15:55:14