djangodockerdocker-composecelerydjango-celery

AttributeError: 'Logger' object has no attribute 'warn'


I'm trying to connect celery to my django project via docker. But when starting the worker container, I get the following error -

File "/usr/local/lib/python3.13/site-packages/kombu/transport/redis.py", line 92, in <module>
 crit, warn = logger.critical, logger.warn
                               ^^^^^^^^^^^
 AttributeError: 'Logger' object has no attribute 'warn'

My requirements.txt file:

Django==4.2.7
psycopg==3.1.13
celery[redis]==5.3.6
django-celery-beat==2.5.0
redis==5.0.1

My dockerfile:

FROM python:3.13.0a1-alpine3.18

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY requirements /temp/requirements
RUN apk add postgresql-client build-base postgresql-dev
RUN pip install -r /temp/requirements/local.txt

WORKDIR /myproject

COPY . .

EXPOSE 8000

My docker-compose.yml:

 redis:
    image: redis:7.2.3-alpine3.18
    ports:
      - '6379:6379'
    restart: always

  worker:
    build:
      context: .
    command: >
      sh -c "celery -A config worker -l INFO"
    restart: always
    depends_on:
      - redis

Structure of my project:

enter image description here

The src folder contains apps.

I tried to solve this problem but I failed. Please tell me what the problem might be and how to solve it. Thank you!


Solution

  • Thanks to @erny I was able to solve this problem.

    The problem was that in python 3.13 logger.warn was removed.

    Therefore, in order for everything to work correctly at the moment of writing the answer, use python version up to 3.13 (not inclusive)