pip install confluent-kafka gives error in mac

Viewed 679

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

2 Answers

Install the librdkafka library

brew install librdkafka

Set the environment variables

export C_INCLUDE_PATH=/opt/homebrew/Cellar/librdkafka/1.8.2/include
export LIBRARY_PATH=/opt/homebrew/Cellar/librdkafka/1.8.2/lib

Then you can install it through pip install

Omotto's answer solves the issue.

Just a note, replace the version 1.8.2 with the version you have. You can check the version by going to this path /opt/homebrew/Cellar/librdkafka(Since Homebrew is installed here if it's an M1 Mac). The name of the folder inside will give you the version number.

Related