15

i'm trying to import talib, but I'm getting this error:

ImportError: libta_lib.so.0: cannot open shared object file: No such file or directory

When I start python like this:

LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" python

import talib works.

How can I turn this solution into a fixed one?

1

5 Answers 5

17

I had the same issue. See below for what I did to fix it.

installing

wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
Sudo make install
pip install numpy

If you don't have it installed

pip install TA-Lib 

if you do have it installed

pip install --upgrade --force-reinstall TA-Lib

hope this helps someone :)

3
  • 2
    --prefix=/usr means you're installing software in a region reserved for use by your operating system's package manager. It works, sure, but it'll cause trouble later -- means an attempt to install an OS package for the same software would fail unless forced, for example. See unix.stackexchange.com/questions/8656/… for discussion. Nov 11, 2017 at 3:54
  • Does it matter in which directory you wget ?
    – Fredovsky
    Dec 11, 2017 at 10:19
  • @Fredovsky no it doesn't, that just dictates the location which you're downloading the tar.gz to.
    – KamKam
    Jan 8, 2020 at 17:36
15

add the foldername to ldconfig:

sudo -s 
echo "include /usr/local/lib" >> /etc/ld.so.conf
ldconfig 
11

For me, following worked:

/usr/local/lib
  1. put above line to /etc/ld.so.conf
  2. execute sudo ldconfig.
1

You may well find that ldconfig is already configured to search '/usr/local/lib', and in this case, you only need to reload it, using sudo ldconfig.

(I would post this as a comment, but insufficient reputation.)

0

If you are arriving at this Stack Overflow question and you're working with shared libraries that are being cross compiled for different platforms/architectures, consider that you might be trying to access a shared object that was compiled for another platform by mistake.

I was getting this error while building my own shared libraries on a darwin/arm64 system for a linux/amd64 docker container. After rebuilding my shared libraries while being careful to build for the right architecture, I no longer received the cannot open shared object file: No such file or directory error and my shared library was accessible to my python application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.