pip install -r requirements.txt [Errno 2] No such file or directory: 'requirements.txt'

105,916

Solution 1

If you are using a virtual environment just use the following line.

pip freeze > requirements.txt

It commands to create the requirements file first.

Or in dockerfile, RUN pip freeze > requirements.txt .

Solution 2

If you are facing this issue while using a docker or flowing getting started guide from docker site then you need to update your Docker file.

just add following line to create the requirements.txt file before the line "RUN pip install --no-cache-dir -r requirements.txt" in your Dockerfile

RUN pip freeze > requirements.txt

Solution 3

A better way of doing this is write this on the root directory of your terminal:

find . -regex '.*requirements.txt$'

It will search in your root directory and all subfolders for a file called requirements.txt. After the command response, you can get the directory and run the pip install -r requirements.txt on it.

Solution 4

Try using this in your terminal then go to the directory and use the pip install command.

find -name "requirements.txt"

Solution 5

I tried this and solved:

COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
Share:
105,916
Admin
Author by

Admin

Updated on October 11, 2021

Comments

  • Admin
    Admin over 2 years

    I am setting up the base for a django project, I have cloned a repo and I have just created a virtual environment for the project in the same directory. But when I try to run the command pip install -r requirements.txt in the project directory I get this error:

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

    I believe I'm just running it in the wrong directory, but I don't really know where I should run it. Do you have any idea where the file could be located?