Dockerfile:pip 安装因 requirements.txt 失败(但对单个包成功)
Dockerfile: pip install fails with requirements.txt (but succeeds with individual packages)
我正在尝试在 docker 容器中安装一些软件包,但从 requirements.txt 文件安装时出现问题。这一行:
RUN python3.8 -m pip install -r requirements.txt
失败并出现错误:
...
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
requirements.txt 文件如下:
numpy
opencv-python
torch
但是,当一次安装这些软件包时一切正常:
RUN python3.8 -m pip install numpy
RUN python3.8 -m pip install opencv-python
RUN python3.8 -m pip install torch
有什么解决办法吗?
*** 编辑 ***
到那时为止的 Dockerfile:
FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt ./
你可以尝试一些事情。根据您的基础映像,您可以 运行 以这种方式进行 pip 安装:
RUN pip install -r requirements.txt
另一种选择是更改您的 requirements.txt,使其受版本控制。然后你就可以确定你有兼容的版本,这通常是一个很好的做法。例如:
torch==1.8.0
在没有缓存的情况下再次尝试 运行 Docker:
docker build -no-cache
或者您可以检查这个答案:
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. when updating Django
我正在尝试在 docker 容器中安装一些软件包,但从 requirements.txt 文件安装时出现问题。这一行:
RUN python3.8 -m pip install -r requirements.txt
失败并出现错误:
...
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
requirements.txt 文件如下:
numpy
opencv-python
torch
但是,当一次安装这些软件包时一切正常:
RUN python3.8 -m pip install numpy
RUN python3.8 -m pip install opencv-python
RUN python3.8 -m pip install torch
有什么解决办法吗?
*** 编辑 ***
到那时为止的 Dockerfile:
FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt ./
你可以尝试一些事情。根据您的基础映像,您可以 运行 以这种方式进行 pip 安装:
RUN pip install -r requirements.txt
另一种选择是更改您的 requirements.txt,使其受版本控制。然后你就可以确定你有兼容的版本,这通常是一个很好的做法。例如:
torch==1.8.0
在没有缓存的情况下再次尝试 运行 Docker:
docker build -no-cache
或者您可以检查这个答案:
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. when updating Django