Unable install Django through Dockerfile

Issue

when I run ‘docker build .’ command,
"ERROR: Invalid requirement: ‘Django=>4.0.4’ (from line 1 of /requirements.txt)
WARNING: You are using pip version 22.0.4; however, version 22.1 is available.
You should consider upgrading via the ‘/usr/local/bin/python -m pip install –upgrade pip’ command."

this error shows up. I have upgraded pip to the latest version. When I check version of pip , it shows 22.1.
But when I run docker build command again, nothing changes.
I have upgraded from this /usr/local/bin/python location. but still nothing changed.

I am using Ubuntu 20.04, python version is 3.8.

my docker file:

FROM python:3.8-alpine
MAINTAINER Kanan App Developer

ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

RUN mkdir /app
WORKDIR /app
COPY ./app /app

RUN adduser -D user
USER user

requirements.txt file:

Django=>4.0.4
djangorestframework=>3.13.1

Solution

=> is not a valid realtional operator for greater than or equal to.

The valid operator is >=. So, your requirements.txt file should be:

Django>=4.0.4
djangorestframework>=3.13.1

Answered By – Aadarsha

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published