kafka-python icon indicating copy to clipboard operation
kafka-python copied to clipboard

Cannot import name 'KafkaProducer' from 'kafka'

Open Xiezhibin opened this issue 6 years ago • 6 comments

I run the code "from kafka import KafkaProducer" in my jupyter-notebook, it report an error that "Cannot import name 'KafkaProducer' from 'kafka' (unknown location)"。

But the code work well in terminal。

Python: 3.7.7 in anaconda virtual environment

kafka-python:2.0.1

Xiezhibin avatar Apr 26 '20 02:04 Xiezhibin

Getting the same error, could you fix it? Edit: nvm, was able to fix it by reinstalling with pipenv

mamilov avatar May 07 '20 13:05 mamilov

Please install the package kafka-python, not kafka. This behaviour may happen if you had 2 packages installed at some time. If you end up with such a situation, please reinstall kafka-python using:

pip uninstall kafka
pip uninstall kafka-python
pip install kafka-python

You have to uninstall it completely first because just installing a new version will not reset the loader properly. Sorry for the trouble.

tvoinarovskyi avatar May 07 '20 14:05 tvoinarovskyi

thanks a lot have a great day

markysie avatar Mar 06 '23 09:03 markysie