gpt4 book ai didi

python-3.x - 如何使用 Linux alpine 3.13 在 Docker 镜像上安装 hdf5

转载 作者:行者123 更新时间:2023-12-03 17:09:17 25 4
gpt4 key购买 nike

我正在用 python 构建一个 Docker 镜像 3.7.10 (Linux Alpine v 3.13 ) 但是当使用 docker build . 构建镜像时包裹hdf5安装过程中会失败。这是我的 Dockerfile:

FROM python:3.7.10-alpine3.13

RUN mkdir /app
WORKDIR /app
COPY requirements.txt /requirements.txt
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
RUN apk add --update --no-cache --virtual .tmp gcc libc-dev linux-headers
RUN apk add --no-cache jpeg-dev zlib-dev mariadb-dev libffi-dev openblas-dev libgfortran lapack-dev build-base openssl-dev
RUN apk add --no-cache hdf5 hdf5-dev
RUN pip install -r /requirements.txt
RUN apk --no-cache del build-base

ENV PYTHONUNBUFFERED 1
COPY . /app/

CMD ["uwsgi", "my_app"]
要求.txt 文件:
h5py==2.10.0
numpy==1.19.2
我试过使用和不使用 --no-binary标志但仍然没有运气。有人能够在这个 Alpine 版本上安装那个库吗?
错误日志:
    17858 |   __pyx_t_1 = H5Ovisit_by_name(__pyx_v_loc_id, __pyx_v_obj_name, __pyx_v_idx_type, __pyx_v_order, __pyx_v_op, __pyx_v_op_data, __pyx_v_lapl_id); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1641, __pyx_L1_error)
| ^~~~~~~~~~~~~~~~
In file included from /usr/include/H5Apublic.h:22,
from /usr/include/hdf5.h:23,
from /tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/api_compat.h:27,
from /tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/defs.c:654:
/usr/include/H5Opublic.h:213:15: note: declared here
213 | H5_DLL herr_t H5Ovisit_by_name3(hid_t loc_id, const char *obj_name,
| ^~~~~~~~~~~~~~~~~
/tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/defs.c: In function '__pyx_f_4h5py_4defs_H5Pget_driver_info':
/tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/defs.c:21768:13: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
21768 | __pyx_t_1 = H5Pget_driver_info(__pyx_v_plist_id); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2016, __pyx_L1_error)
| ^
In file included from /usr/include/H5public.h:32,
from /usr/include/hdf5.h:22,
from /tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/api_compat.h:27,
from /tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/defs.c:654:
/tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/defs.c: In function '__pyx_f_4h5py_4defs_H5Sencode':
/tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/defs.c:34528:15: error: too few arguments to function 'H5Sencode2'
34528 | __pyx_t_1 = H5Sencode(__pyx_v_obj_id, __pyx_v_buf, __pyx_v_nalloc); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3303, __pyx_L1_error)
| ^~~~~~~~~
In file included from /usr/include/hdf5.h:38,
from /tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/api_compat.h:27,
from /tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/defs.c:654:
/usr/include/H5Spublic.h:129:15: note: declared here
129 | H5_DLL herr_t H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl);
| ^~~~~~~~~~
In file included from /usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:21,
from /usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from /tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/api_compat.h:26,
from /tmp/pip-install-fkianwj6/h5py_dfa9366c1fdb47e98e9e2e8de85ac21e/h5py/defs.c:654:
At top level:
/usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1464:1: warning: '_import_array' defined but not used [-Wunused-function]
1464 | _import_array(void)
| ^~~~~~~~~~~~~
error: command 'gcc' failed with exit status 1
----------------------------------------

最佳答案

似乎我使用了错误的旧 h5py 版本( h5py==2.10.0 )。更新到 h5py==3.2.1 时,以下设置运行良好内要求.txt .

FROM python:3.7.10-alpine3.13

RUN mkdir /app
WORKDIR /app
COPY requirements.txt /requirements.txt
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
RUN apk add --update --no-cache --virtual .tmp gcc libc-dev linux-headers
RUN apk add --no-cache jpeg-dev zlib-dev mariadb-dev libffi-dev openblas-dev libgfortran lapack-dev build-base openssl-dev
RUN apk add --no-cache hdf5-dev
RUN pip install -r /requirements.txt
RUN apk --no-cache del build-base

ENV PYTHONUNBUFFERED 1
COPY . /app/

CMD ["uwsgi", "my_app"]

要求.txt 文件:
h5py==3.2.1
numpy==1.20.1
感谢@jordanvrtanoski 和@valiano 的反馈。

关于python-3.x - 如何使用 Linux alpine 3.13 在 Docker 镜像上安装 hdf5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66705108/

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