offset-null1
offset-null1

Reputation: 163

Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

I'm trying to build a docker image on my ubuntu 18.04 machine and I have located requirements.txt in the same building directory but still its showing up this error.

Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

requirements.txt is to install python modules using pip3.

requirement.txt:

numpy opencv-contrib-python opencv-python scikit-image pillow imutils scikit-learn matplotlib progressbar2 beautifulsoup4 pandas matplotlib re2 regex json argparse pickle

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

Upvotes: 15

Views: 37465

Answers (1)

Michael Anckaert
Michael Anckaert

Reputation: 953

I suspect that you haven't copied over your requirements.txt file to your Docker image.

Typically you add the following lines to your Dockerfile to copy your requirements.txt file and install it using pip:

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

If you don't explicitly copy over anything to your Docker image your image has no data save for what is on the base image.

Upvotes: 38

Related Questions