python操作kafka报错:return ‘<SimpleProducer batch=%s>‘ % self.async
1.遇到的问题C:\ProgramData\Anaconda3\python.exe C:/git/base_function/kafka_usage.pyTraceback (most recent call last):File "C:/git/base_function/kafka_usage.py", line 6, in <module>from kafka import K
·
1.遇到的问题 C:\ProgramData\Anaconda3\python.exe C:/git/base_function/kafka_usage.py Traceback (most recent call last): File "C:/git/base_function/kafka_usage.py", line 6, in <module> from kafka import KafkaProducer File "C:\ProgramData\Anaconda3\lib\site-packages\kafka\__init__.py", line 23, in <module> from kafka.producer import KafkaProducer File "C:\ProgramData\Anaconda3\lib\site-packages\kafka\producer\__init__.py", line 4, in <module> from .simple import SimpleProducer File "C:\ProgramData\Anaconda3\lib\site-packages\kafka\producer\simple.py", line 54 return '<SimpleProducer batch=%s>' % self.async ^ SyntaxError: invalid syntax
2.解决方法
因为py3.7里面async已经变成了关键字。所以导致了不兼容。
解决办法:
使用最新的kafka版本,但是pyPI上的kafka还没有被替换成最新的,可以使用下面的方法升级kafka python
pip install kafka-python
同时也需要安装kafka
pip install kafka
更多推荐
已为社区贡献1条内容
所有评论(0)