How to fix Dockerfile numba install error: ERROR: Dependency OpenBLAS not found

Problem

During a Docker build, you encounter the following error while installing the numba package using pip install numba or similar:

../scipy/meson.build:216:9: ERROR: Dependency "OpenBLAS" not found, tried pkgconfig

Solution

You need to install the gfortran package in the container:

sudo apt -y install libopenblas-dev

Add the following line to your Dockerfile (for deb-based distributions):

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y gfortran libopenblas-dev && rm -rf /var/lib/apt/lists/*

gfortran-dev is required in addition to gfortran to build numba.