ImportError: cannot open shared object file: No such file or directory

Pafnouti picture Pafnouti · May 23, 2014 · Viewed 7.8k times · Source

I'm trying to use arac with PyBrain, and when I call net.convertToFastNetwork(), or when I try to import arac.pybrainbridge (import arac works fine), I get this error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pafnouti/Documents/Project/arac/src/python/arac/pybrainbridge.py", line 51, in <module>
    import arac.cppbridge as cppbridge
  File "/home/pafnouti/Documents/Project/arac/src/python/arac/cppbridge.py", line 31, in <module>
    _cppbridge = swig_import_helper()
  File "/home/pafnouti/Documents/Project/arac/src/python/arac/cppbridge.py", line 26, in swig_import_helper
    _mod = imp.load_module('_cppbridge', fp, pathname, description)
ImportError: libarac.so: cannot open shared object file: No such file or directory

Which comes from this code:

    try:
        fp, pathname, description = imp.find_module('_cppbridge', [dirname(__file__)])
    except ImportError:
        import _cppbridge
        return _cppbridge
    if fp is not None:
        try:
            print fp,"\n", pathname,"\n", description
            _mod = imp.load_module('_cppbridge', fp, pathname, description) # Fails here
            print "OK!"
        finally:
            fp.close()
        return _mod

I have the same error if I call directly import _cppbridge. I've seen this kind of error here, so I tried to solve it as it said:

locate libarac.so 
/usr/local/lib/libarac.so

Here libarac.so is a link to another place, but even when copying it into /usr/local/lib it doesn't work

ls -l
total 0
lrwxrwxrwx. 1 root root 10 May 23 03:05 libarac.so -> libarac.so

I tried to change LD_LIBRARY_PATH with:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

And /etc/ld.so.conf by adding a new line with /usr/local/lib and calling sudo ldconfig, but it didn't change anything.

NB: I'm on Fedora 20.

I don't know if it has a link, but since I couldn't manage to compile the tests for arac, in SConstruct I commented some lines:

# Then compile the tests.
#testenv = Environment(LIBS=['arac', 'gtest'], CPPPATH=CPPPATH, LIBPATH=LIBPATH)
#test = testenv.Program('test-arac', Glob('src/cpp/tests/*.cpp'))


swigenv = Environment(SWIGFLAGS=['-python', '-c++', '-outdir', 'src/python/arac'],
                      CPPPATH=CPPPATH + NUMPYPATH + PYTHONPATH,
                      LIBS=['arac'],
                      FRAMEWORKSFLAGS=frameworksflags,
                      LINKFLAGS=linkflags,
                      LIBPATH=LIBPATH,
                      LDMODULEPREFIX='src/python/arac/_',
                      LDMODULESUFFIX = '.so',
                      )
swig = swigenv.LoadableModule('cppbridge',
                             ['src/swig/cppbridge.i'])

# Declare some dependencies.
#Depends(test, lib)
Depends(swig, lib)

Answer