简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM