问题
I'm trying to install the python confluent-kafka package using pip. I'm attempting this on an aws ec2 instance that is running amazon linux (version Amazon Linux AMI release 2016.09). I'm simply doing:
pip install pip install confluent-kafka
This however produces the following error:
In file included from confluent_kafka/src/confluent_kafka.c:17:0:
confluent_kafka/src/confluent_kafka.h:21:32: fatal error: librdkafka/rdkafka.h: No such file or directory
#include <librdkafka/rdkafka.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
To resolve this, I did two things:
1) Followed the instructions on this page and added the file /etc/yum.repos.d/confluent.repo with the contents:
[Confluent.dist]
name=Confluent repository (dist)
baseurl=http://packages.confluent.io/rpm/3.0/6
gpgcheck=1
gpgkey=http://packages.confluent.io/rpm/3.0/archive.key
enabled=1
[Confluent]
name=Confluent repository
baseurl=http://packages.confluent.io/rpm/3.0
gpgcheck=1
gpgkey=http://packages.confluent.io/rpm/3.0/archive.key
enabled=1
2) attempted to install the librdkafka library using this command:
sudo yum clean all
sudo yum install -y librdkafka1 librdkafka-devel
Yum spits out this error however:
Error: Package: librdkafka1-0.9.1_confluent3.0.1-1.el7.x86_64 (Confluent.dist)
Requires: openssl-libs
Error: Package: librdkafka1-0.9.1_confluent3.0.1-1.el7.x86_64 (Confluent.dist)
Requires: libsasl2.so.3()(64bit)
After some googling, I tried:
sudo ln /usr/lib64/libsasl2.so.2 /usr/lib64/libsasl2.so.3
This had no effect. I tried doing a yum upgrade and this also did not solve the issue. After much googling, this kafka user group post is the only remotely helpful thing I can find, but it sadly does not contain a solution to the problem.
I'd really like to get kafka python up and running on this instance, so any suggestions would be greatly appreciated.
回答1:
Amazon Linux 2016.19 seems to be based on RHEL 6 so you will need to reference Confluent's RHEL 6 Yum repo as described in Confluent docs, namely by writing the following to /etc/yum.repos.d/confluent
:
[Confluent.dist]
name=Confluent repository (dist)
baseurl=http://packages.confluent.io/rpm/3.1/6
gpgcheck=1
gpgkey=http://packages.confluent.io/rpm/3.1/archive.key
enabled=1
[Confluent]
name=Confluent repository
baseurl=http://packages.confluent.io/rpm/3.1
gpgcheck=1
gpgkey=http://packages.confluent.io/rpm/3.1/archive.key
enabled=1
Followed by:
$ sudo yum clean all
$ sudo yum install gcc librdkafka1 librdkafka-devel cyrus-sasl-devel openssl-libs python-devel
$ pip install confluent-kafka (possibly in a virtualenv)
来源:https://stackoverflow.com/questions/41731752/libsasl-dependency-issues-when-installing-librdkafka1-via-yum-on-aws-linux-machi