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

非公有网络部署MWAA(Airflow2.10.1)时依赖冲突求助

解决MWAA私有网络部署中PyArrow依赖冲突问题

问题场景

在私有网络环境部署Airflow 2.10.1版本的MWAA,使用的requirements文件内容如下:

--find-links /usr/local/airflow/plugins
--no-index

pyarrow==14.0.2
filelock==3.15.4
platformdirs==4.2.2
pydantic==2.8.2
virtualenv==20.26.3
distlib==0.3.8
snowflake-connector-python==3.12.1
snowflake-sqlalchemy==1.6.1
astronomer-cosmos==1.7.1
apache-airflow-providers-snowflake==5.7.0

因私有网络无法访问标准约束文件,未配置约束文件,但部署时出现以下错误:

WARNING: Constraints should be specified for requirements.txt. Please see https://docs.aws.amazon.com/mwaa/latest/userguide/working-dags-dependencies.html#working-dags-dependencies-test-create

Forcing local constraints
Defaulting to user installation because normal site-packages is not writeable
Looking in links: /usr/local/airflow/plugins
ERROR: Cannot install pyarrow==14.0.2 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested pyarrow==14.0.2
The user requested (constraint) pyarrow==14.0.2
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip to attempt to solve the dependency conflict

本地使用aws-mwaa-local-runner搭配相同plugins文件夹(内含pyarrow-14.0.2-cp311-cp311-manylinux_2_28_x86_64.whl)部署正常,无startup.sh文件。

解决方法

1. 移除requirements中的PyArrow版本指定

由于plugins目录已存在对应版本的PyArrow wheel包,且--find-links会优先查找本地文件,直接删除requirements中的pyarrow==14.0.2行即可。pip会自动从本地plugins目录安装匹配的PyArrow版本,避免手动指定版本与本地约束产生冲突。

修改后的requirements文件:

--find-links /usr/local/airflow/plugins
--no-index

filelock==3.15.4
platformdirs==4.2.2
pydantic==2.8.2
virtualenv==20.26.3
distlib==0.3.8
snowflake-connector-python==3.12.1
snowflake-sqlalchemy==1.6.1
astronomer-cosmos==1.7.1
apache-airflow-providers-snowflake==5.7.0

2. 显式指定本地wheel文件安装PyArrow

在requirements中直接使用wheel文件名指定安装,而非版本号,避免pip将版本号解析为约束条件:

--find-links /usr/local/airflow/plugins
--no-index

pyarrow-14.0.2-cp311-cp311-manylinux_2_28_x86_64.whl
filelock==3.15.4
platformdirs==4.2.2
pydantic==2.8.2
virtualenv==20.26.3
distlib==0.3.8
snowflake-connector-python==3.12.1
snowflake-sqlalchemy==1.6.1
astronomer-cosmos==1.7.1
apache-airflow-providers-snowflake==5.7.0

3. 生成本地约束文件适配私有网络

若必须保留版本指定,可在本地mwaa-local-runner环境生成适配的约束文件:

  • 进入本地runner环境,执行pip freeze > constraints.txt
  • 将生成的constraints.txt上传至私有网络可访问的存储(如S3私有桶)
  • 在requirements文件顶部添加-c s3://your-private-bucket/path/constraints.txt(替换为实际路径),同时保留--find-links和--no-index

此方法既满足MWAA对约束文件的要求,又能规避依赖冲突。

内容的提问来源于stack exchange,提问作者Sam Helmich

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 14:17:16