confluent-kafka-python
confluent-kafka-python copied to clipboard
confluent_kafka/cimpl.cpython-36m-x86_64-linux-gnu.so: undefined symbol: rd_kafka_event_AlterConsumerGroupOffsets_result
Description
On centos 7, getting error when importing confluent kafka 2.2.0 in python script. The confluent-kafka module was built using the source along with librdkafka.
Getting below error when importing the module
Traceback (most recent call last):
File "
How to reproduce
-
Build the confluent-kafka rpm using the source with below steps
-
dnf install -y python3-devel
-
sed -i -E 's/(name = ")/\1python3-/g' setup.py
-
python3 setup.py sdist bdist_rpm --release="%{timestamp}%{?dist}" --spec-only --build-requires=python3-devel
-
SPEC=$(basename $(find -name *.spec) )
-
rpmbuild -bb dist/"${SPEC}" --define "_sourcedir
pwd/dist" --define "_specdirpwd/dist" --define "_rpmdirpwd/dist" --define 'timestamp %(date +"%Y%m%d%H%M")' --define "debug_package %{nil}" -
Prerequisite to create the confluent-kafka rpm, create the librdkafka as below
-
curl -L https://github.com/confluentinc/librdkafka/archive/refs/tags/v2.2.0.tar.gz | tar xzf -
-
cd librdkafka-2.2.0/
-
./configure --prefix=/usr
-
make -j
-
make install
Install the rpm created on the centos box and then try to import the module.
Checklist
Please provide the following information:
- [ ] confluent-kafka-python and librdkafka version (
confluent_kafka.version()andconfluent_kafka.libversion()): - [ ] Apache Kafka broker version:
- [ ] Client configuration:
{...} - [ ] Operating system:
- [ ] Provide client logs (with
'debug': '..'as necessary) - [ ] Provide broker log excerpts
- [ ] Critical issue
Is installation from the wheel not working using python3 -m pip install confluent_kafka?
I got the same error on Ubuntu 22.04 after following a similar procedure. The solution was to remove the OS-provided librdkafka:
sudo apt purge librdkafka1 librdkafka-dev "librdkafka++1"
Both confluent-kafka=1.9 (from PyPI) and confluent-kafka=2.2 (built locally) seem to be working fine after this.
Is installation from the wheel not working using
python3 -m pip install confluent_kafka?
Binary wheels are not published for all compatible Python versions, and wheels built from source don't include librdkafka.so for some reason.