Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 729
Harvey Avatar asked Jan 20 '21 12:01

Harvey


1 Answers

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

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

like image 54
OneCricketeer Avatar answered Oct 23 '22 00:10

OneCricketeer