dpkp / kafka-python

Python client for Apache Kafka
http://kafka-python.readthedocs.io/
Apache License 2.0
5.58k stars 1.4k forks source link

Kafka-python errore #2436

Open alimajed92 opened 4 months ago

alimajed92 commented 4 months ago

I'm encountering an issue with importing KafkaProducer from the kafka module. Here's the code I'm using:

from kafka import KafkaProducer

The error message I'm receiving is: "cannot import name 'KafkaProducer' from partially initialized module 'kafka' (most likely due to a circular import)".

I'm running Kafka on Docker, and it's functioning properly. My goal is simply to send messages from my Python file to Kafka.

I've tried uninstalling and reinstalling the kafka-python library, but I'm still having the same error.

Thanks for the help!

alimajed92 commented 4 months ago

The issue stemmed from the naming of my Python file, which coincidentally was named kafka.py. To resolve this, I renamed the file to something else.

After resolving the naming conflict, I encountered another error: "No module named 'kafka.vendor.six.moves'". The solution to this error was to uninstall kafka-python and install kafka-python-ng. https://stackoverflow.com/questions/77287622/modulenotfounderror-no-module-named-kafka-vendor-six-moves-in-dockerized-djan