Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pwaterz opened this issue Mar 21, 2017 · 10 comments

Comments

@pwaterz
Copy link

pwaterz commented Mar 21, 2017

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?

@edenhill
Copy link
Contributor

Hi @pwaterz ,

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

@pwaterz
Copy link
Author

pwaterz commented Mar 21, 2017

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

@edenhill
Copy link
Contributor

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

@pwaterz
Copy link
Author

pwaterz commented Mar 21, 2017

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/

@edenhill
Copy link
Contributor

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'

@pwaterz
Copy link
Author

pwaterz commented Mar 21, 2017

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!

@edenhill
Copy link
Contributor

Dup of #65

@dogyy0119
Copy link

I just ldconfig
after make install , then it works

@vikramj74
Copy link

Thanks @dogyy0119 , ldconfig worked for me.

@idati
Copy link

idati commented Nov 25, 2019

I just ldconfig
after make install , then it works

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants