0

Previosly I have error like this SyntaxError on "self.async" when running python kafka producer

Based on the answer, best answer is switch from kafka package to kafka-python package, this is what the detail of my docker-compose configuration, I think to change the docker image because of the docker log still similar

  kafka:
    image: wurstmeister/kafka
    container_name: kafka
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: localhost
      KAFKA_ADVERTISED_PORT: 9092
      KAFKA_CREATE_TOPICS: "segmentation"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  zookeeper:
    image: wurstmeister/zookeeper
    container_name: zookeeper
    ports:
      - "2181:2181"

Do I need to change the docker compose? If yes what to change?

Nabih Bawazir
  • 6,381
  • 7
  • 37
  • 70
  • Why do you feel you need to change the docker configuration? Could you please edit your question to point out what is the current problem? – Pratik Thakare Jun 16 '23 at 08:52
  • The docker log still similar – Nabih Bawazir Jun 16 '23 at 09:01
  • It should not require any changes based on your change (kafka package to kafka-python package). – Jishan Shaikh Jun 16 '23 at 09:16
  • @JishanShaikh I think so, but without change in docker image, the error still same, because the code is still same – Nabih Bawazir Jun 16 '23 at 09:19
  • Our team has been using [this](https://hub.docker.com/r/confluentinc/cp-kafka/) docker image; if you are willing to try it. Also, if you don't know, Zookeeper is being deprecated in favor of KRaft. – Jishan Shaikh Jun 16 '23 at 09:20
  • So Kafka with python3 versions use asynchronous in place of async as in python2. You are getting this error because your python3 is trying to compile Kafka for python2. First: pip uninstall kafka-python (to remove python2 version of kafka) followed by Kafka Installation using python3.8 -m pip install kafka-python should do the magic. From: https://github.com/dpkp/kafka-python/issues/1566#issuecomment-598655410 – Jishan Shaikh Jun 16 '23 at 09:26
  • 1
    In last comment the quote should make sure you have installed python version same as you have been using in your system. – Jishan Shaikh Jun 16 '23 at 09:27
  • https://limascloud.com/2022/01/02/docker-compose-kafka-setup-confluent-cloud/ – Nabih Bawazir Jun 19 '23 at 03:31

0 Answers0