gpt4 book ai didi

python - fatal error : *. h : No such file or directory. 运行 docker build 命令为 python 项目创建图像时

转载 作者:太空宇宙 更新时间:2023-11-04 08:26:56 27 4
gpt4 key购买 nike

有一个 python 项目,我在“requirement.txt”文件的帮助下定义了依赖项。依赖项之一是 gmpy2。当我运行 docker build -t myimage . 命令时,在执行 setup.py install 的步骤中出现以下错误。

In file included from src/gmpy2.c:426:0:
src/gmpy.h:252:20: fatal error: mpfr.h: No such file or directory
include "mpfr.h"

类似的另外两个错误是:

In file included from appscript_3x/ext/ae.c:14:0:
appscript_3x/ext/ae.h:26:27: fatal error: Carbon/Carbon.h: No such file
or directory
#include <Carbon/Carbon.h>

In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>

现在的问题是我如何定义或安装成功构建镜像所需的这些内部依赖项。根据我的理解,gmpy2 是用 C 语言编写的,并且依赖于其他三个 C 库:GMP、MPFR 和 MPC,但无法找到它。

以下是我的 docker 文件:

FROM python:3

COPY . .

RUN pip install -r requirement.txt

CMD [ "python", "./mike/main.py" ]

最佳答案

安装此 apt install libgmp-dev libmpfr-dev libmpc-dev 额外依赖项,然后 RUN pip install -r requirement.txt我认为它会起作用,您将能够安装所有依赖项并构建 docker 镜像。

FROM python:3

COPY . .

RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
libmpc-dev \
libgmp-dev \
libmpfr-dev

RUN pip install -r requirement.txt

CMD [ "python", "./mike/main.py" ]

如果 apt 未运行,您可以使用 Linux 作为基础镜像。

关于python - fatal error : *. h : No such file or directory. 运行 docker build 命令为 python 项目创建图像时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56230886/

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