from kafka import KafkaClient ImportError: No module named kafka

Viewed 6240

I installed Python version 3.8.3 and 2.7.16, pip install pykafka, and pip install kafka-python. When I try to run the Python program with installed modules I get an error:

from kafka import KafkaClient ImportError: No module named kafka
from pykafka import KafkaClient ImportError: No module named pykafka

What could be the issue here?

2 Answers

I'm assuming you want this for python 3.8.3. Use either pip3 install kafka-python or python3 -m pip install kafka-python. If you aren't using one of those python versions you can ditch it and then your original command will work. The problem is that you have 2 pythons, but you aren't experienced enough to divine which is being used at any given time.

Maybe you can try setting up a virtual env using pipenv for instance. Probably the package has been installed for the python version you are not using.

Related