pip install confluence-kafka 在 mac 中出现错误

Muh*_*yis 3 python django macos kafka-python

当我尝试时 pip install confluent-kafka出现以下错误


#include <librdkafka/rdkafka.h>
             ^~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command '/usr/bin/gcc' failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

我正在使用 python 版本 3.9 和 macOs Monterey

omo*_*tto 9

安装 librdkafka 库

brew install librdkafka

设置环境变量

export C_INCLUDE_PATH=/usr/local/Cellar/librdkafka/2.2.0/include
export LIBRARY_PATH=/usr/local/Cellar/librdkafka/2.2.0/lib
Run Code Online (Sandbox Code Playgroud)

然后就可以通过安装了pip install