No module named ‘kafka’ – Python project run through bazel

I’m a Java developer and a python beginner. I’m trying to import kafka into a python service I’m writing. This is being run through bazel. I installed kafka-python using

pip install kafka-python

I was able to do kafka calls through a jupyter notebook so can confirm that the kafka-python library is installed. I imported the kafka-python library in my code using

from kafka.admin import KafkaAdminClient

However, when I try to run the service

bazel run //service:service_image.binary

I get the error ModuleNotFoundError: No module named 'kafka'. I tried looking for how to inject dependency for kafka, like we do for java using maven/pom/gradle using a version of 'org.apache.kafka:kafka_2.13:<version>' but couldn’t find anything. I also tried uninstalling and reinstalling kafka-python. Any pointers would be appreciated.

Read more here: Source link