confluent-kafka-python icon indicating copy to clipboard operation
confluent-kafka-python copied to clipboard

ImportError: librdkafka.so.1: cannot open shared object file: No such file or directory

Open pwaterz opened this issue 9 years ago • 10 comments

Currently running into this error

$ python2.7
Python 2.7.12 (default, Jun 28 2016, 17:49:25)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from confluent_kafka import Consumer, KafkaError
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/confluent_kafka/__init__.py", line 2, in <module>
    from .cimpl import (Consumer,
ImportError: librdkafka.so.1: cannot open shared object file: No such file or directory

When trying to import the package. I'm running this on REHL 5 and installed the package via

pip2.7 install confluent-kafka

Any ideas?

pwaterz avatar Mar 21 '17 18:03 pwaterz

Hi @pwaterz ,

did you install librdkafka first? If so, how? (yum, build from source, ..?)

edenhill avatar Mar 21 '17 18:03 edenhill

I did, I built it from source

 ls -la /usr/local/include/librdkafka/
total 200
drwxr-xr-x 2 root root  4096 Mar 21 10:38 .
drwxr-xr-x 8 root root  4096 Mar  9 12:02 ..
-rwxr-xr-x 1 root root 65663 Mar 21 10:38 rdkafkacpp.h
-rwxr-xr-x 1 root root 99635 Mar 21 10:38 rdkafka.h

pwaterz avatar Mar 21 '17 18:03 pwaterz

It could be that the linker doesnt look in /usr/local/lib, you can verify this by doing: LD_LIBRARY_PATH=/usr/local/lib python -m confluent_kafka

If that works it means you should add /usr/local/lib to /etc/ld.so.conf and rerun ldd (iirc).

Another alternative is to install librdkafka in the system location right away, by:

cd librdkafka
./configure --prefix=/usr
make clean all
sudo make install

edenhill avatar Mar 21 '17 18:03 edenhill

Doesn't look like that's the issue

$ LD_LIBRARY_PATH=/usr/local/lib python2.7 -m confluent_kafka
/usr/bin/python2.7: No module named confluent_kafka.__main__; 'confluent_kafka' is a package and cannot be directly executed

The kafka lib is installed here

/usr/lib64/python2.7/site-packages/confluent_kafka/

pwaterz avatar Mar 21 '17 18:03 pwaterz

Sorry, try this: LD_LIBRARY_PATH=/usr/local/lib python2.7 -m confluent_kafka.kafkatest.verifiable_client

Or just start python with LD_LIBRARY_PATH=... and do the manual 'import confluent_kafka'

edenhill avatar Mar 21 '17 19:03 edenhill

That did not error. I will try and fix the linking in the library and get back to you. Thanks a lot for your time!

pwaterz avatar Mar 21 '17 19:03 pwaterz

Dup of #65

edenhill avatar Apr 10 '17 15:04 edenhill

I just ldconfig after make install , then it works

dogyy0119 avatar Nov 08 '18 01:11 dogyy0119

Thanks @dogyy0119 , ldconfig worked for me.

vikramj74 avatar Mar 26 '19 13:03 vikramj74

I just ldconfig after make install , then it works

@edenhill please can you add it to the README, that would be great :-)

idati avatar Nov 25 '19 05:11 idati