Search code examples
dockernumpypipalpine-linux

Can't install wheels on docker for numpy


this is my first time running Docker and I am having issues creating the image. This is the code inside my docker file

FROM alpine:latest

ENV PATH /usr/local/bin:$PATH

RUN apk add --no-cache python3 py3-pip
RUN apk add py3-pip && pip3 install --upgrade pip

WORKDIR /backend

COPY . /backend

RUN pip3 install wheel
RUN pip3 install numpy
RUN pip3 --no-cache-dir install -r requirements.txt

Under requirements.txt, I have numpy==1.23.1.

The relevant error codes are

#12 8.606   Building wheel for numpy (pyproject.toml): started
#12 22.30   Building wheel for numpy (pyproject.toml): finished with status 'error'

#12 22.34 ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
------
executor failed running [/bin/sh -c pip3 install numpy]: exit code: 1

I tried searching for solutions but they mentioned that once you upgraded PIP, things should install fine. In this case, they still do not work well.

Do give any advice!


Solution

  • Try pip3 install --extra-index-url https://alpine-wheels.github.io/index numpy isntead. Does that work? If so, I can explain in an answer

    The above comment by FlyingTeller provided a solution for the problem.