Kafka-python问题解决

消费者代码

from kafka import KafkaConsumer

consumer = KafkaConsumer('reimport-app-douyin2', auto_offset_reset='earliest',bootstrap_servers='bigdata-test01:6667')

for msg in consumer:

print(msg)

主要是加了一个auto_offset_reset='earliest',查看所有的Kafka消息

mac

1、python创建的kafka消费者报错

kafka.errors.UnsupportedCodecError: UnsupportedCodecError: Libraries for snappy compression codec not found

解决方式:

brew install snappy

brew install python-snappy

windows

2、python创建kafka消费者报错

AttributeError: module 'snappy' has no attribute 'decompress'

解决:

在win系统的python安装python-snappy库

从以下去下载对应的python-snappy版本

https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-snappy


分享到:


相關文章: