在 ubuntu 上构建 R (cran) + rpy2 -> libRblas.so 未找到

fli*_*inz 4 ubuntu r building rpy2

我正在尝试在 ubuntu(11.04,natty narwhal)上构建 R(尝试 2.14.2 和 2.15)和 rpy2(2.2.6,python 2.7.1),以将其部署到自定义目录(以下称为 /home/ me/lib/R),因为我没有 root 访问权限,但需要比服务器上可用的版本更新。

构建等详细信息,但即使在运行 rpy2 测试时,我也总是收到以下错误:

/home/me/lib/pythonlib/lib/python/rpy2/rinterface/__init__.py in <module>()
---> 87 from rpy2.rinterface._rinterface import *
ImportError: libRblas.so: cannot open shared object file: No such file or directory
WARNING: Failure executing file: <experiments/arrangement/test_smacof_arrange.py>
Run Code Online (Sandbox Code Playgroud)

我确定我正在调用正确的 rpy2 模块(我的自定义模块),该模块是针对自定义构建的 R 版本构建的。为此,我正在执行以下操作:

  1. 我首先在 ubuntu 上构建 R-base

    wget http://cran.r-project.org/bin/linux/ubuntu/natty/r-base_2.14.2.orig.tar.gz
    # untar and go to directory
    
    # enable-R-shblib flag is needed for rpy2 linking, enable-BLAS-shlib was included
    # because I hoped to solve the problem, which doesnt change anything however
    ./configure --enable-R-shlib --enable-BLAS-shlib --prefix=/home/me/lib/R
    make
    make install
    
    Run Code Online (Sandbox Code Playgroud)
  2. 然后我针对这个 R 版本构建 rpy2

    wget http://pypi.python.org/packages/source/r/rpy2/rpy2-2.2.6.tar.gz
    # untar and go to directory
    
    # build rpy2, by providing the r-home-lib and r-home flags, and deploy to custom dir
    python setup.py build --r-home /home/me/lib/R --r-home-lib /home/me/lib/R/lib64/R/lib install --home /home/me/lib/pythonlib
    
    Run Code Online (Sandbox Code Playgroud)

    我还调整了我的 pythonpath 以在 /home/me/lib/pythonlib 中查找模块,所以问题不存在。python 构建返回正确的配置(注意 Rblas 出现在这里!)

    Configuration for R as a library:
    include_dirs: ('/home/me/lib/R/lib64/R/include',)
    libraries: ('R', 'Rblas', 'Rlapack')
    library_dirs: ('/home/me/lib/R/lib64/R/lib',)
    extra_link_args: ()
    
    Run Code Online (Sandbox Code Playgroud)

我试图追查错误,但没有尽头。/home/me/lib/R/lib64/R/lib 包含 libRblas.so,但是有一件事看起来很奇怪,那就是 libRblas.so 没有从 libR.so 正确链接,但我不确定这会导致错误,我也不知道如何修复它。

>> ldd -d libR.so

linux-vdso.so.1 =>  (0x00007fffcec58000)
libRblas.so => not found
libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007fe63d21d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe63cf97000)
...
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激!

Chr*_*per 5

对于遇到此问题的其他人,我能够通过确保将 R 库添加到 bashrc 中的库路径来解决它:

export LD_LIBRARY_PATH="R-install-location/lib65/R/lib:$LD_LIBRARY_PATH"
Run Code Online (Sandbox Code Playgroud)