2

I'm trying to install some packages in a docker container, and there is a problem when installing from a requirements.txt file. This line:

RUN python3.8 -m pip install -r requirements.txt

fails with the error:

...
Collecting torch
  Downloading torch-1.8.0-cp38-cp38-manylinux1_x86_64.whl (735.5 MB)
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    torch from https://files.pythonhosted.org/packages/89/c1/72e9050d3e31e4df983f6e06799a1a4c896427c1e5645a6d810940944b60/torch-1.8.0-cp38-cp38-manylinux1_x86_64.whl#sha256=fa1e391cca3937d5dea31f31a1a80a01bd4a8062c039448c254bbf5a58eb0787 (from -r requirements.txt (line 3)):
        Expected sha256 fa1e391cca3937d5dea31f31a1a80a01bd4a8062c039448c254bbf5a58eb0787
             Got        d5466637c17c3ae0c81c00d93a0b7c8d8428cfd216f54953a11d0788ea7b74fb

The requirements.txt file is the following:

numpy
opencv-python
torch

However, when installing these packages one at a time everything works fine:

RUN python3.8 -m pip install numpy
RUN python3.8 -m pip install opencv-python
RUN python3.8 -m pip install torch

Any ideas how to solve this?

*** EDIT ***

Dockerfile up to that point:

FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt ./
Chiel
  • 1,865
  • 1
  • 11
  • 24
giladrv
  • 1,024
  • 1
  • 9
  • 22

1 Answers1

1

You could try a couple of things. Depending on your base image, you could run pip install in this way:

RUN pip install -r requirements.txt

Another option would be to change your requirements.txt such that it is version controlled. Then you can be sure you have compatible versions and is a good practice in general. Eg.:

torch==1.8.0

Try to run Docker again with without caches, you can use the --no-cache flag:

docker build --no-cache .

Or you could check this answer:

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. when updating Django

Community
  • 1
  • 1
Chiel
  • 1,865
  • 1
  • 11
  • 24