Search code examples
pythondjangomacoskafka-python

pip install confluent-kafka gives error in mac


When i tried pip install confluent-kafka got the following error


#include <librdkafka/rdkafka.h>
             ^~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command '/usr/bin/gcc' failed with exit code 1

I'm using python version 3.9 and macOs Monterey


Solution

  • Install the librdkafka library

    brew install librdkafka

    Set the environment variables

    export C_INCLUDE_PATH=/usr/local/Cellar/librdkafka/2.2.0/include
    export LIBRARY_PATH=/usr/local/Cellar/librdkafka/2.2.0/lib
    

    Then you can install it through pip install