当 运行 python kafka 生产者时 "self.async" 上的语法错误
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
我之前看到过相同的错误,但我使用的是 from kafka import KafkaProducer
我的新 python 脚本使用 from kafka.producer import KafkaProducer
但我仍然收到 self.async 错误
您需要安装 kafka-python
,而不是 kafka
包。如果安装了kafka
,那么你需要卸载它并替换为另一个
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
我之前看到过相同的错误,但我使用的是 from kafka import KafkaProducer
我的新 python 脚本使用 from kafka.producer import KafkaProducer
但我仍然收到 self.async 错误
您需要安装 kafka-python
,而不是 kafka
包。如果安装了kafka
,那么你需要卸载它并替换为另一个