'Running the same docker config a few months later results in "ValueError: numpy.ndarray size changed"
We've built a docker image in Summer '21 and it ran fine until December. Now, after having deleted the docker cache, it doesn't run anymore.
The error is:
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
There are quite a lot of related SO questions. The answers tend to be similar:
- reinstall
numpy - use
numpyversion X - use
--no-cache-diroption onpip install - use a new pip version
We've tried all of it (upgrading pip by adding the latest version to requirements.txt). A specific numpy version was not in our requirements.txt, I thought that could be the cause here, but after adding a few very different versions without success, I am out of ideas.
We're not even sure whether purging the docker cache played a role.
This is the minimal repro:
main.py:
from string_grouper import match_strings, match_most_similar
requirements.txt:
string_grouper==0.1.1
Dockerfile:
FROM amancevice/pandas:1.3.1-slim
# for string_grouper
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get install g++ -y \
&& apt-get clean
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN python -m pip install --no-cache-dir -r requirements.txt
WORKDIR /app
COPY . /app
RUN useradd appuser && chown -R appuser /app
USER appuser
CMD ["python", "main.py"]
What else can we try to troubleshoot this?
EDIT: I believe the likeliest solution is "explicitly install numpy version X". In that case, the question would just be how to find the right one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
