【问题标题】:Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'无法打开需求文件:[Errno 2] 没有这样的文件或目录:'requirements.txt'
【发布时间】:2020-09-16 14:31:50
【问题描述】:

我正在尝试在我的 ubuntu 18.04 机器上构建一个 docker 映像,并且我已将 requirements.txt 定位在同一构建目录中,但仍然显示此错误。

无法打开需求文件:[Errno 2] 没有这样的文件或目录:'requirements.txt' 命令'/bin/sh -c pip3 install -r requirements.txt'返回一个非零代码:1

requirements.txt 是使用 pip3 安装 python 模块。

requirement.txt:

numpy opencv-contrib-python opencv-python scikit-image 枕头 imutils scikit-learn matplotlib progressbar2 beautifulsoup4 pandas matplotlib re2 正则表达式 json argparse 泡菜

DockerFile:

FROM nvidia/cuda:10.1-cudnn7-runtime-ubuntu18.04

COPY requirements.txt /home/usr/app/requirements.txt
WORKDIR /home/usr/app/

RUN apt-get update && apt-get install -y python3 python3-pip sudo
RUN pip3 install -r requirements.txt

FROM tensorflow/tensorflow:latest-gpu-jupyter

【问题讨论】:

  • 请提供完整的 docker 文件

标签: python docker dockerfile


【解决方案1】:

我怀疑你没有将你的 requirements.txt 文件复制到你的 Docker 映像中。

通常您将以下行添加到 Dockerfile 以复制您的 requirements.txt 文件并使用 pip 安装它:

COPY requirements.txt /tmp/requirements.txt
RUN python3 -m pip install -r /tmp/requirements.txt

如果您没有明确地将任何内容复制到您的 Docker 映像,则您的映像没有保存基础映像上的数据。

【讨论】:

  • 谢谢,它成功了。但现在我面临新问题 Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9s4fxvhr/opencv-python/ The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1 我是 docker 新手,所以不知道如何解决这个问题。
  • 如果您可以更改您的原始问题以包含您的 Dockerfile 和您的 requirements.txt 文件,我们可以更好地了解发生了什么。
  • 完成。而且我不太确定我是否可以使用 2 个基本图像。我想合并 2 个图像以在单个容器中使用。
猜你喜欢
  • 1970-01-01
  • 2016-03-18
  • 2022-10-15
  • 2020-10-09
  • 2023-01-31
  • 2021-11-05
  • 2022-12-30
  • 2019-05-19
  • 1970-01-01
相关资源
最近更新 更多