Python3 pip install --target Fails with NumPy

Viewed 29

I'm trying to build a docker image via copying all dependencies into the image.

First, in the same directory as the Dockerfile

python3 -m pip install . --target site-packages

Then,

WORKDIR /src
COPY . .
ENV PYTHONPATH /src/site-packages:$PYTHONPATH
ENV PATH $PATH:/src/site-packages/bin

The image builds fine, but if I try to import numpy or pandas, everything falls apart:

>>> import numpy
[...] Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed. [...]

This is a common NumPy error (see website), but I can't find anything on how to solve if using the --target flag.

Thanks in advance for any and all help!

0 Answers
Related