Sign in
Log inSign up

How can I solve this Python error : ImportError cannot import name KafkaProducer

Anas Rabei's photo
Anas Rabei
·May 1, 2016

I have a very strange problem. I wrote a spark streaming job that monitor an HDFS directory, reads the newly added files, and send the file content to Kafka.

When submitting the job I got that error

ImportError: cannot import name KafkaProducer

While the error is very simple, it is weird because I could import KafkaProducer using python and pyspark shells without any problem.

I tried to reboot the machine but the situation still the same.

You can check the code of the spark streaming job from here

http://pastebin.com/mpKkMkph

Does anyone here have any idea about this problem?