在基于 Alpine 的 libreoffice 映像上安装 pandas/numpy

Install pandas/numpy on Alpine-based libreoffice image

我需要一个 Docker 安装了 LibreOffice 和 python pandas 的图像。我已经确定,由于 Oracle 的 JRE/JDK 要求,LibreOffice 现在存在一系列许可问题。所以,我开始 FROM linuxserver/libreoffice:7.2.2 在我的 Docker 图像中。现在,问题是当我尝试使用虚拟环境和 requirements.txt 文件(仅行它是 pandas>=1.4.0,<1.5)安装 pandas 时,如下所示:

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install dependencies:
COPY requirements.txt .
RUN /opt/venv/bin/python3 -m pip install --upgrade pip && \
    pip install -r requirements.txt

...我收到这个巨大的错误:

#9 50.08       Collecting oldest-supported-numpy>=0.10
#9 50.08         Downloading oldest_supported_numpy-2022.4.18-py3-none-any.whl (3.9 kB)
#9 50.08       Collecting numpy==1.19.3
#9 50.08         Downloading numpy-1.19.3.zip (7.3 MB)
#9 50.08            ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.3/7.3 MB 2.3 MB/s eta 0:00:00
#9 50.08         Installing build dependencies: started
#9 50.08         Installing build dependencies: finished with status 'done'
#9 50.08         Getting requirements to build wheel: started
#9 50.08         Getting requirements to build wheel: finished with status 'done'
#9 50.08         Preparing metadata (pyproject.toml): started
#9 50.08         Preparing metadata (pyproject.toml): finished with status 'error'
#9 50.08         error: subprocess-exited-with-error
#9 50.08
#9 50.08         × Preparing metadata (pyproject.toml) did not run successfully.
#9 50.08         │ exit code: 1
#9 50.08         ╰─> [236 lines of output]
#9 50.08             Running from numpy source directory.
#9 50.08             setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
#9 50.08               run_build = parse_setuppy_commands()
#9 50.08             Processing numpy/random/_bounded_integers.pxd.in
#9 50.08             Processing numpy/random/_pcg64.pyx
#9 50.08             Processing numpy/random/_philox.pyx
#9 50.08             Processing numpy/random/mtrand.pyx
#9 50.08             Processing numpy/random/_generator.pyx
#9 50.08             Processing numpy/random/_common.pyx
#9 50.08             Processing numpy/random/_mt19937.pyx
#9 50.08             Processing numpy/random/_sfc64.pyx
#9 50.08             Processing numpy/random/_bounded_integers.pyx.in
#9 50.08             Processing numpy/random/bit_generator.pyx
#9 50.08             Cythonizing sources
#9 50.08             blas_opt_info:
#9 50.08             blas_mkl_info:
#9 50.08             customize UnixCCompiler
#9 50.08               libraries mkl_rt not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             blis_info:
#9 50.08               libraries blis not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             openblas_info:
#9 50.08               libraries openblas not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             atlas_3_10_blas_threads_info:
#9 50.08             Setting PTATLAS=ATLAS
#9 50.08               libraries tatlas not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             atlas_3_10_blas_info:
#9 50.08               libraries satlas not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             atlas_blas_threads_info:
#9 50.08             Setting PTATLAS=ATLAS
#9 50.08               libraries ptf77blas,ptcblas,atlas not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             atlas_blas_info:
#9 50.08               libraries f77blas,cblas,atlas not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             accelerate_info:
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             /tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/system_info.py:1914: UserWarning:
#9 50.08                 Optimized (vendor) Blas libraries are not found.
#9 50.08                 Falls back to netlib Blas library which has worse performance.
#9 50.08                 A better performance should be easily gained by switching
#9 50.08                 Blas library.
#9 50.08               if self._calc_info(blas):
#9 50.08             blas_info:
#9 50.08               libraries blas not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             /tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/system_info.py:1914: UserWarning:
#9 50.08                 Blas (http://www.netlib.org/blas/) libraries not found.
#9 50.08                 Directories to search for the libraries can be specified in the
#9 50.08                 numpy/distutils/site.cfg file (section [blas]) or by setting
#9 50.08                 the BLAS environment variable.
#9 50.08               if self._calc_info(blas):
#9 50.08             blas_src_info:
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             /tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/system_info.py:1914: UserWarning:
#9 50.08                 Blas (http://www.netlib.org/blas/) sources not found.
#9 50.08                 Directories to search for the sources can be specified in the
#9 50.08                 numpy/distutils/site.cfg file (section [blas_src]) or by setting
#9 50.08                 the BLAS_SRC environment variable.
#9 50.08               if self._calc_info(blas):
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             non-existing path in 'numpy/distutils': 'site.cfg'
#9 50.08             lapack_opt_info:
#9 50.08             lapack_mkl_info:
#9 50.08               libraries mkl_rt not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             openblas_lapack_info:
#9 50.08               libraries openblas not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             openblas_clapack_info:
#9 50.08               libraries openblas,lapack not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             flame_info:
#9 50.08               libraries flame not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             atlas_3_10_threads_info:
#9 50.08             Setting PTATLAS=ATLAS
#9 50.08               libraries lapack_atlas not found in /opt/venv/lib
#9 50.08               libraries tatlas,tatlas not found in /opt/venv/lib
#9 50.08               libraries lapack_atlas not found in /usr/local/lib
#9 50.08               libraries tatlas,tatlas not found in /usr/local/lib
#9 50.08               libraries lapack_atlas not found in /usr/lib
#9 50.08               libraries tatlas,tatlas not found in /usr/lib
#9 50.08             <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             atlas_3_10_info:
#9 50.08               libraries lapack_atlas not found in /opt/venv/lib
#9 50.08               libraries satlas,satlas not found in /opt/venv/lib
#9 50.08               libraries lapack_atlas not found in /usr/local/lib
#9 50.08               libraries satlas,satlas not found in /usr/local/lib
#9 50.08               libraries lapack_atlas not found in /usr/lib
#9 50.08               libraries satlas,satlas not found in /usr/lib
#9 50.08             <class 'numpy.distutils.system_info.atlas_3_10_info'>
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             atlas_threads_info:
#9 50.08             Setting PTATLAS=ATLAS
#9 50.08               libraries lapack_atlas not found in /opt/venv/lib
#9 50.08               libraries ptf77blas,ptcblas,atlas not found in /opt/venv/lib
#9 50.08               libraries lapack_atlas not found in /usr/local/lib
#9 50.08               libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
#9 50.08               libraries lapack_atlas not found in /usr/lib
#9 50.08               libraries ptf77blas,ptcblas,atlas not found in /usr/lib
#9 50.08             <class 'numpy.distutils.system_info.atlas_threads_info'>
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             atlas_info:
#9 50.08               libraries lapack_atlas not found in /opt/venv/lib
#9 50.08               libraries f77blas,cblas,atlas not found in /opt/venv/lib
#9 50.08               libraries lapack_atlas not found in /usr/local/lib
#9 50.08               libraries f77blas,cblas,atlas not found in /usr/local/lib
#9 50.08               libraries lapack_atlas not found in /usr/lib
#9 50.08               libraries f77blas,cblas,atlas not found in /usr/lib
#9 50.08             <class 'numpy.distutils.system_info.atlas_info'>
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             lapack_info:
#9 50.08               libraries lapack not found in ['/opt/venv/lib', '/usr/local/lib', '/usr/lib']
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             /tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/system_info.py:1748: UserWarning:
#9 50.08                 Lapack (http://www.netlib.org/lapack/) libraries not found.
#9 50.08                 Directories to search for the libraries can be specified in the
#9 50.08                 numpy/distutils/site.cfg file (section [lapack]) or by setting
#9 50.08                 the LAPACK environment variable.
#9 50.08               return getattr(self, '_calc_info_{}'.format(name))()
#9 50.08             lapack_src_info:
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             /tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/system_info.py:1748: UserWarning:
#9 50.08                 Lapack (http://www.netlib.org/lapack/) sources not found.
#9 50.08                 Directories to search for the sources can be specified in the
#9 50.08                 numpy/distutils/site.cfg file (section [lapack_src]) or by setting
#9 50.08                 the LAPACK_SRC environment variable.
#9 50.08               return getattr(self, '_calc_info_{}'.format(name))()
#9 50.08               NOT AVAILABLE
#9 50.08
#9 50.08             numpy_linalg_lapack_lite:
#9 50.08               FOUND:
#9 50.08                 language = c
#9 50.08                 define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]
#9 50.08
#9 50.08             /usr/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
#9 50.08               warnings.warn(msg)
#9 50.08             running dist_info
#9 50.08             running build_src
#9 50.08             build_src
#9 50.08             building py_modules sources
#9 50.08             creating build
#9 50.08             creating build/src.linux-x86_64-3.9
#9 50.08             creating build/src.linux-x86_64-3.9/numpy
#9 50.08             creating build/src.linux-x86_64-3.9/numpy/distutils
#9 50.08             building library "npymath" sources
#9 50.08             Could not locate executable gfortran
#9 50.08             Could not locate executable f95
#9 50.08             Could not locate executable ifort
#9 50.08             Could not locate executable ifc
#9 50.08             Could not locate executable lf95
#9 50.08             Could not locate executable pgfortran
#9 50.08             Could not locate executable nvfortran
#9 50.08             Could not locate executable f90
#9 50.08             Could not locate executable f77
#9 50.08             Could not locate executable fort
#9 50.08             Could not locate executable efort
#9 50.08             Could not locate executable efc
#9 50.08             Could not locate executable g77
#9 50.08             Could not locate executable g95
#9 50.08             Could not locate executable pathf95
#9 50.08             Could not locate executable nagfor
#9 50.08             don't know how to compile Fortran code on platform 'posix'
#9 50.08             Traceback (most recent call last):
#9 50.08               File "/tmp/tmpqq2gyha2_in_process.py", line 363, in <module>
#9 50.08                 main()
#9 50.08               File "/tmp/tmpqq2gyha2_in_process.py", line 345, in main
#9 50.08                 json_out['return_val'] = hook(**hook_input['kwargs'])
#9 50.08               File "/tmp/tmpqq2gyha2_in_process.py", line 164, in prepare_metadata_for_build_wheel
#9 50.08                 return hook(metadata_directory, config_settings)
#9 50.08               File "/tmp/pip-build-env-6370icr8/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 157, in prepare_metadata_for_build_wheel
#9 50.08                 self.run_setup()
#9 50.08               File "/tmp/pip-build-env-6370icr8/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 248, in run_setup
#9 50.08                 super(_BuildMetaLegacyBackend,
#9 50.08               File "/tmp/pip-build-env-6370icr8/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 142, in run_setup
#9 50.08                 exec(compile(code, __file__, 'exec'), locals())
#9 50.08               File "setup.py", line 508, in <module>
#9 50.08                 setup_package()
#9 50.08               File "setup.py", line 500, in setup_package
#9 50.08                 setup(**metadata)
#9 50.08               File "/tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/core.py", line 169, in setup
#9 50.08                 return old_setup(**new_attr)
#9 50.08               File "/tmp/pip-build-env-6370icr8/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 165, in setup
#9 50.08                 return distutils.core.setup(**attrs)
#9 50.08               File "/usr/lib/python3.9/distutils/core.py", line 148, in setup
#9 50.08                 dist.run_commands()
#9 50.08               File "/usr/lib/python3.9/distutils/dist.py", line 966, in run_commands
#9 50.08                 self.run_command(cmd)
#9 50.08               File "/usr/lib/python3.9/distutils/dist.py", line 985, in run_command
#9 50.08                 cmd_obj.run()
#9 50.08               File "/tmp/pip-build-env-6370icr8/overlay/lib/python3.9/site-packages/setuptools/command/dist_info.py", line 31, in run
#9 50.08                 egg_info.run()
#9 50.08               File "/tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/command/egg_info.py", line 24, in run
#9 50.08                 self.run_command("build_src")
#9 50.08               File "/usr/lib/python3.9/distutils/cmd.py", line 313, in run_command
#9 50.08                 self.distribution.run_command(command)
#9 50.08               File "/usr/lib/python3.9/distutils/dist.py", line 985, in run_command
#9 50.08                 cmd_obj.run()
#9 50.08               File "/tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/command/build_src.py", line 144, in run
#9 50.08                 self.build_sources()
#9 50.08               File "/tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/command/build_src.py", line 155, in build_sources
#9 50.08                 self.build_library_sources(*libname_info)
#9 50.08               File "/tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/command/build_src.py", line 288, in build_library_sources
#9 50.08                 sources = self.generate_sources(sources, (lib_name, build_info))
#9 50.08               File "/tmp/pip-install-m9ffqtsd/numpy_f52b823899c842e29073892fb891d2ea/numpy/distutils/command/build_src.py", line 378, in generate_sources
#9 50.08                 source = func(extension, build_dir)
#9 50.08               File "numpy/core/setup.py", line 663, in get_mathlib_info
#9 50.08                 raise RuntimeError("Broken toolchain: cannot link a simple C program")
#9 50.08             RuntimeError: Broken toolchain: cannot link a simple C program
#9 50.08             [end of output]
#9 50.08
#9 50.08         note: This error originates from a subprocess, and is likely not a problem with pip.
#9 50.08       error: metadata-generation-failed
#9 50.08
#9 50.08       × Encountered error while generating package metadata.
#9 50.08       ╰─> See above for output.
#9 50.08
#9 50.08       note: This is an issue with the package mentioned above, not pip.
#9 50.08       hint: See above for details.
#9 50.08       [end of output]
#9 50.08
#9 50.08   note: This error originates from a subprocess, and is likely not a problem with pip.
#9 50.09 error: subprocess-exited-with-error
#9 50.09
#9 50.09 × pip subprocess to install build dependencies did not run successfully.
#9 50.09 │ exit code: 1
#9 50.09 ╰─> See above for output.
#9 50.09
#9 50.09 note: This error originates from a subprocess, and is likely not a problem with pip.
------
executor failed running [/bin/sh -c /opt/venv/bin/python3 -m pip install --upgrade pip &&     pip install -r requirements.txt]: exit code: 1

我查看了 here 中列出的几个答案,它们看起来与我得到的非常相似,但这个讨论似乎已经过时了。 None 我从那里尝试过的解决方案有效。

似乎 BLAS 和其他一些项目没有正确安装在 Alpine 映像上。我已经尝试了很多不同的方法来做到这一点并且 none 到目前为止都有效。如何在 this Alpine Docker image 上安装 pandas?

更新

我愿意使用 Debian 或基于 Ubuntu 的 Docker 映像,只要它预装了 LibreOffice。到目前为止,我在网上找到的唯一预装了 LibreOffice 的图片是 Alpine 图片...

我想你可以使用 openjdk,但我不确定。

至于pandas,它缺少只能用apk安装的BLAS C库。您可以通过 运行 apk add openblas 轻松做到这一点,但您可能还需要 openblas-dev 包。