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

Docker构建Python服务镜像失败:xeddsa安装报错解决

Docker构建Python镜像时xeddsa==0.6.0安装失败的解决办法

问题现象

基于python:3.8-slim-buster构建镜像,执行docker image build -t server:latest .时,安装xeddsa==0.6.0环节出现连续错误:

  • 初始报错:找不到cmake,导致python setup.py egg_info执行失败
  • 补装cmake后,又出现AttributeError: module 'posixpath' has no attribute 'append'
    已尝试升级setuptools但无效,requirements.txt仅包含cryptography==38.0.1和xeddsa==0.6.0。

解决步骤

在Dockerfile中添加系统依赖安装步骤,需安装以下包:

  • build-essential:提供基础编译工具链
  • cmake:xeddsa编译依赖的构建工具
  • protobuf-compiler:处理protobuf相关编译需求
  • libsodium-dev:xeddsa依赖的加密库开发文件

修改后的Dockerfile示例

FROM python:3.8-slim-buster

# 安装系统依赖并清理apt缓存以减小镜像体积
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    cmake \
    protobuf-compiler \
    libsodium-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# 根据实际服务脚本修改启动命令
CMD ["python", "server.py"]

内容的提问来源于stack exchange,提问作者Silent Tree

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 21:15:44