I installed the kafka-python package for Python. I have a kafka producer and consumer running. I want the python code to read the kafka topic and print out the messages.
My python code is below:
import sys
from kafka import KafkaConsumer
def kafkatest():
print "Step 1 complete"
consumer=KafkaConsumer('test',bootstrap_servers=['localhost:9092'])
for message in consumer:
print "Next message"
print message
if __name__=="__main__":
kafkatest()
I get the following error:
C:\Python27>python.exe kafka.py Traceback (most recent call last): File "kafka.py", line 2, in <module>
from kafka import KafkaConsumer File "C:\Python27\kafka.py", line 2, in <module>
from kafka import KafkaConsumer ImportError: cannot import name KafkaConsumer
Any suggestions on what I am missing here?