ECS部署Airflow 1.10.9出现pandas_gbq导入报错 指定pandas-gbq版本安装失效
运行环境与已知现象
- 生产环境部署在ECS服务器,使用Airflow 1.10.9版本搭建调度集群,依赖统一通过requirements.txt文件管控安装
- requirements.txt中初始Airflow依赖声明为:
apache-airflow[aws,celery,crypto,gcp,jdbc,mysql,password,postgres,slack,statsd]==1.10.9 - 自pandas_gbq 0.15.0版本公开发布后,Airflow集群Web UI持续弹出导入报错:
cannot import name '_check_google_client_version' from 'pandas_gbq.gbq'
根因排查结论
- Airflow 1.10.9版本内置的bigquery_hook模块,依赖从pandas_gbq库导入
_check_google_client_version方法完成初始化 - pandas_gbq从0.15.0版本开始,已彻底移除该内部方法,直接触发导入链路报错
- 版本匹配的代码校验结论:
- Airflow 1.10.9版本的bigquery_hook.py第40行存在对上述方法的导入逻辑
- pandas-gbq 0.14.1版本的gbq.py第37行存在
_check_google_client_version方法的完整定义 - pandas-gbq 0.15.0版本的gbq.py文件中已无该方法的定义
已尝试的无效操作
- 在requirements.txt中追加全链路版本锁定规则:
pandas==0.25.3pandas-gbq==0.14.1apache-airflow==1.10.9
- 重新执行依赖安装流程后,Airflow容器内最终仍自动安装pandas-gbq 0.15.0版本,手动设置的版本锁定规则未生效
诉求
- 梳理可在Airflow容器内稳定安装pandas-gbq 0.14.1适配版本的落地方案
内容的提问来源于stack exchange,提问作者Yohei Onishi
相关产品推荐
相关产品推荐

