apache-kafka 无法安装confluent-kafka:“致命错误:图书馆Kafka/读者Kafka.h:无此文件或目录”

im9ewurl  于 2022-11-01  发布在  Apache
关注(0)|答案(7)|浏览(262)

我在我的项目中使用了confluent-kafka Python客户端。我试图用这个客户端创建一个Docker映像。
我面临以下错误:-


# 11 8.015 [pipenv.exceptions.InstallError]:       In file included from /tmp/pip-install-so_whhii/confluent-kafka_9d9553bf46cf489bb25fcb2ac7698747/src/confluent_kafka/src/Admin.c:17:

# 11 8.015 [pipenv.exceptions.InstallError]:       /tmp/pip-install-so_whhii/confluent-kafka_9d9553bf46cf489bb25fcb2ac7698747/src/confluent_kafka/src/confluent_kafka.h:23:10: fatal error: librdkafka/rdkafka.h: No such file or directory

# 11 8.015 [pipenv.exceptions.InstallError]:          23 | #include <librdkafka/rdkafka.h>

# 11 8.015 [pipenv.exceptions.InstallError]:             |          ^~~~~~~~~~~~~~~~~~~~~~

# 11 8.015 [pipenv.exceptions.InstallError]:       compilation terminated.

# 11 8.015 [pipenv.exceptions.InstallError]:       error: command '/usr/bin/gcc' failed with exit code 1

# 11 8.016 [pipenv.exceptions.InstallError]:       [end of output]

根据我的搜索,它与苹果M1构建的librdkafka有关。

dl5txlt9

dl5txlt91#

请参考Github issue。M1的问题是Homebrew安装在不同的位置,因此需要通过在.zshrc文件中包含这些行来将这些变量添加到环境中

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

oyt4ldly2#

Confluent的工程师们显然非常关注他们的付费客户,在Python 3.10发布了很多很多个月之后,他们仍然没有发布包含该软件包的二进制文件的3.10 wheel。
https://github.com/confluentinc/confluent-kafka-python/issues/1219
你有两个选择:1,运行Python 3.9; 2,在安装confluent-kafka之前通过apt安装librdkafka-dev(对于debian基本映像)。
这个问题与Apple M1相同-即,没有为包含二进制文件的平台预先构建的轮子,但如果您试图构建一个amd64 Linux映像,则修复起来要容易得多(通过安装librdkafka-dev)。

rkue9o1l

rkue9o1l3#

在非M1的Mac(英特尔)上,Python 3.10.6,我用以下代码解决了这个问题

export C_INCLUDE_PATH=/usr/local/Cellar/librdkafka/1.9.2/include     
export LIBRARY_PATH=/usr/local/Cellar/librdkafka/1.9.2/lib
axzmvihb

axzmvihb4#

如果你在M1上的Docker容器中安装汇合Kafka,这对我很有帮助。

RUN apt-get update && \
  apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && \
  cd /tmp && git clone https://github.com/edenhill/librdkafka.git && \
  cd librdkafka && git checkout tags/v1.9.0 && \
  ./configure && make && make install && \
  cd ../ && rm -rf librdkafka
hfwmuf9z

hfwmuf9z5#

为你的苹果M1预先构建的confluent-kafka-python二进制轮子似乎不存在。
因此,为了安装这个包,pip试图从源代码构建它自己。但是librdkafka看起来像是没有安装,因为你得到了librdkafka/rdkafka.h: No such file or directory错误。
您可以从源代码中找到针对不同平台here的具体安装说明。

lzfw57am

lzfw57am6#

我在虚拟环境中尝试使用Python 3.9.13解决了这个问题。

6qfn3psc

6qfn3psc7#

在一个非M1的Mac上,Python 3.10.2,我用brew install librdkafka解决了这个问题。

相关问题