SyntaxError on "self.async" when running python kafka producer

Question:

Traceback (most recent call last):
  File "//producer.py", line 1, in <module>
    from kafka.producer import KafkaProducer
  File "/usr/local/lib/python3.9/site-packages/kafka/__init__.py", line 23, in <module>
    from kafka.producer import KafkaProducer
  File "/usr/local/lib/python3.9/site-packages/kafka/producer/__init__.py", line 4, in <module>
    from .simple import SimpleProducer
  File "/usr/local/lib/python3.9/site-packages/kafka/producer/simple.py", line 54
    return '<SimpleProducer batch=%s>' % self.async
                                              ^
SyntaxError: invalid syntax

I had seen an earlier error identical but I was using from kafka import KafkaProducer

My new python script uses from kafka.producer import KafkaProducerbut I still get the self.async error

Asked By: Harvey

||

Answers:

You need to install kafka-python, not kafka package. If kafka is installed, then you need to pip uninstall kafka and replace with the other

https://github.com/dpkp/kafka-python/issues/1566

Answered By: OneCricketeer
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.