How to Solve NameError: name 'KafkaConsumer' is not defined -- kafka
Solution: Import the 'KafkaConsumer' module
To Solve the error, add the following line to the top of your code.
from kafka import KafkaConsumer
For more information:
Python kafka KafkaConsumer