gpt4 book ai didi

python-3.x - dockerizing 期间无法在 alpine 上安装 pycosat

转载 作者:行者123 更新时间:2023-12-02 18:10:54 27 4
gpt4 key购买 nike

我正在尝试对 django 应用程序进行 docker 化,并且我正在使用 alpine:edge 作为基础图像。并且 pycosat 安装失败并出现错误

In file included from pycosat.c:19:
picosat.c:8150:10: fatal error: sys/unistd.h: No such file or directory
#include <sys/unistd.h>
^~~~~~~~~~~~~~
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1

这是我的 Dockerfile 的样子

FROM alpine:edge
ENV PYTHONBUFFERED 1

RUN apk update && \
apk add --virtual build-deps gcc python3-dev musl-dev \
libffi-dev openssl-dev python3 py3-zmq build-base libzmq zeromq-dev \
curl g++ make zlib-dev linux-headers openssl ca-certificates libevent-dev

RUN pip3 install --upgrade pip setuptools
RUN mkdir /config
ADD /config/requirements.txt /config/
RUN easy_install pyzmq
RUN easy_install pycosat
RUN mkdir /src
WORKDIR /src

我怎样才能安装这个库?我是否遗漏了一些软件包或实用程序之类的东西?

另外我正在使用 docker-compose 来构建它

最佳答案

pycosat 似乎与 Alpine 中使用的 libc 库实现 musl 不兼容。

musl的unistd.h header 位于系统 headers 根文件夹,/usr/include , 而不是 /usr/include/sys和 glibc 一样(glibc 是事实上的 Linux libc 标准),因此编译失败并显示 fatal error: sys/unistd.h: No such file or directory .

作为一种解决方法,您可以在 sys/unistd.h 下创建自己的标题。它将简单地包括 native unistd.h ,在 pycosat 构建步骤之前:

RUN echo "#include <unistd.h>" > /usr/include/sys/unistd.h

关于python-3.x - dockerizing 期间无法在 alpine 上安装 pycosat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52894632/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com