LD_LIBRARY_PATH ignorado pelo Python 2.7

2

Estou tentando instalar o Theano em uma caixa para a qual não tenho acesso root e parece que LD_LIBRARY_PATH é ignorado pela minha instalação do Python 2.7. Como não consigo instalar pacotes no nível do sistema, decidi compilar todos os pacotes (Python, SciPy, OpenBLAS e outros) a partir do código-fonte e instalá-los em $ HOME. Ao testar o SciPy, recebi o erro ERROR: Failure: ImportError (libopenblas.so.0: cannot open shared object file: No such file or directory) , mas parece que a biblioteca está presente e LD_LIBRARY_PATH aponta para a pasta correta. Aqui está a transcrição completa:

wheatstone-acogliat 42% echo $LD_LIBRARY_PATH
/home/seas/grad/acogliat/lib

wheatstone-acogliat 43% python -c "import scipy; scipy.test()"
Running unit tests for scipy
NumPy version 1.9.3
NumPy is installed in /home/seas/grad/acogliat/lib/python2.7/site-packages/numpy
SciPy version 0.16.0
SciPy is installed in /home/seas/grad/acogliat/lib/python2.7/site-packages/scipy
Python version 2.7.10 (default, Sep 28 2015, 21:06:05) [GCC 4.1.2 20080704 (Red Hat 4.1.2-55)]
nose version 1.3.7
/home/seas/grad/acogliat/lib/python2.7/site-packages/numpy/lib/utils.py:95: DeprecationWarning: 'scipy.weave' is deprecated, use 'weave' instead!
  warnings.warn(depdoc, DeprecationWarning)
E.......................................................................K.......................................................................................................EEEEEEEEE.....................................................................................................EE......................................................................S...........EEE...........................................K......................................................................................................
======================================================================
ERROR: Failure: ImportError (libopenblas.so.0: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/seas/grad/acogliat/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/seas/grad/acogliat/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/seas/grad/acogliat/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/seas/grad/acogliat/lib/python2.7/site-packages/scipy/cluster/__init__.py", line 27, in <module>
    from . import vq, hierarchy
  File "/home/seas/grad/acogliat/lib/python2.7/site-packages/scipy/cluster/vq.py", line 89, in <module>
    from . import _vq
ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory

[...MULTIPLE SIMILAR ERRORS OMITTED...]

FAILED (KNOWNFAIL=2, SKIP=1, errors=15)

wheatstone-acogliat 44% ls -al $LD_LIBRARY_PATH
total 47232
drwxr-sr-x  6 acogliat eestudent      512 Sep 28 22:58 ./
drwxr-sr-x 19 acogliat eestudent      512 Sep 28 23:29 ../
drwxr-sr-x  3 acogliat eestudent      512 Sep 28 22:58 cmake/
lrwxrwxrwx  1 acogliat eestudent       30 Sep 28 22:58 libopenblas.a -> libopenblas_opteronp-r0.2.14.a
-rw-r--r--  1 acogliat eestudent 25211324 Sep 28 22:57 libopenblas_opteronp-r0.2.14.a
-rwxr-xr-x  1 acogliat eestudent 12826920 Sep 28 22:57 libopenblas_opteronp-r0.2.14.so*
lrwxrwxrwx  1 acogliat eestudent       31 Sep 28 22:58 libopenblas.so -> libopenblas_opteronp-r0.2.14.so*
lrwxrwxrwx  1 acogliat eestudent       31 Sep 28 22:58 libopenblas.so.0 -> libopenblas_opteronp-r0.2.14.so*
-r-xr-xr-x  1 acogliat eestudent 10193546 Sep 28 21:36 libpython2.7.a*
drwxr-sr-x  3 acogliat eestudent      512 Sep 28 22:46 perl5/
drwxr-sr-x  2 acogliat eestudent      512 Sep 28 21:36 pkgconfig/
drwxr-sr-x 28 acogliat eestudent    14336 Sep 28 21:36 python2.7/

wheatstone-acogliat 45% uname -a
Linux wheatstone 2.6.18-404.el5 #1 SMP Tue Apr 7 12:42:54 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

O que estou perdendo?

    
por Wolfy 29.09.2015 / 15:23

1 resposta

1

Se o código chamar explicitamente dlopen() para localizar arquivos, ele será use LD_LIBRARY_PATH, embora normal python usa $PYTHONPATH para encontrar módulos e bibliotecas. Você também pode definir a matriz sys.path :

import sys
sys.path.append('/mydir')

Lembre-se de exportar o LD_LIBRARY_PATH ou o PYTHONPATH.

    
por 29.09.2015 / 17:43