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

执行pip3 install awscli命令时遇构建依赖错误求助

解决docker:stable镜像中pip3安装awscli失败的问题

问题背景

此前执行pip3 install awscli一切正常,但在docker:stable镜像的CI脚本中执行该命令时失败,报错核心为PyYAML构建依赖缺失。

报错信息

Collecting awscli
Downloading awscli-1.29.3-py3-none-any.whl (4.1 MB)
Collecting s3transfer<0.7.0,>=0.6.0
Downloading s3transfer-0.6.1-py3-none-any.whl (79 kB)
Collecting rsa<4.8,>=3.1.2
Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
Collecting PyYAML<5.5,>=3.10
Downloading PyYAML-5.4.1.tar.gz (175 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /usr/lib/python3.8/site-packages/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpvjbfu4r6

原CI脚本

test:
  image:
    name: docker:stable
  
  before_script:
  - apk update
  - apk add curl py-pip jq bash
  - pip3 install awscli

解决方案

原因分析

docker:stable基于Alpine Linux镜像,默认未安装C语言编译工具链。awscli依赖的PyYAML 5.4.1需要从源码编译生成wheel包,缺少编译依赖会导致构建失败。

修改后的CI脚本

在apk add命令中补充编译所需的依赖包:

test:
  image:
    name: docker:stable
  
  before_script:
  - apk update
  - apk add curl py-pip jq bash gcc python3-dev libffi-dev musl-dev
  - pip3 install awscli

可选优化

若不想安装完整编译工具链,可跳过构建隔离直接安装PyYAML(仅适配Alpine架构):

pip3 install PyYAML==5.4.1 --no-build-isolation

内容的提问来源于stack exchange,提问作者gcpdev-guy

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 02:52:21