我正在尝试通过docker在新的Raspberry pi 4 b中部署小型微服务。该服务目前在Windows PC上运行正常,我什至可以在pi中本地运行该服务。 到目前为止,我已经能够在创建docker映像时将错误追溯到numpy安装。
Collecting numpy==1.19.1
Downloading numpy-1.19.1.zip (7.3 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: still running...
Preparing wheel metadata: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpts0hfzam
cwd: /tmp/pip-install-ozdo_kbb/numpy
Complete output (226 lines):
Processing numpy/random/_bounded_integers.pxd.in
Processing numpy/random/_sfc64.pyx
Processing numpy/random/_philox.pyx
Processing numpy/random/_generator.pyx
Processing numpy/random/_mt19937.pyx
Processing numpy/random/_bounded_integers.pyx.in
Processing numpy/random/_pcg64.pyx
Processing numpy/random/mtrand.pyx
Processing numpy/random/bit_generator.pyx
Processing numpy/random/_common.pyx
我相信稍后会显示重要的信息,这告诉我无法编译numpy的某些库。
creating build/src.linux-armv7l-3.7/numpy/distutils
building library "npymath" sources
Could not locate executable gfortran
Could not locate executable f95
Could not locate executable ifort
Could not locate executable ifc
Could not locate executable lf95
Could not locate executable pgfortran
Could not locate executable f90
Could not locate executable f77
Could not locate executable fort
Could not locate executable efort
Could not locate executable efc
Could not locate executable g77
Could not locate executable g95
Could not locate executable pathf95
Could not locate executable nagfor
don't know how to compile Fortran code on platform 'posix'
Running from numpy source directory.
setup.py:470: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
如何复制: Dockerfile:
FROM python:3.7-slim
WORKDIR /usr/src/app
COPY . .
RUN apt-get update \
&& pip install -r requirements.txt
requirements.txt:
numpy==1.19.1
类似的文章通过向Dockerfile添加更多说明来显示出一些进展,但是我看不出有什么改善
RUN apt-get update \
&& apt-get upgrade \
&& apt-get install libc-dev -y \
&& apt-get install libatlas-base-dev -y \
&& pip install --pre numpy \
&& pip install -r requirements.txt
答案 0 :(得分:1)
苗条的图像没有用于编译numpy的工具。您必须先安装它们,然后才能尝试安装numpy。
FROM python:3.7-slim
WORKDIR /usr/src/app
COPY . .
RUN apt-get update && \
apt-get install -y \
build-essential \
make \
gcc \
&& pip install -r requirements.txt \
&& apt-get remove -y --purge make gcc build-essential \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
pip install -r requirements.txt
干净的构建工具之后的行。
应该会更好。
另一种解决方案是使用python:3.7
图片而不是python:3.7-slim
。
修改
关于aarch64上的numpy的一些链接: