R,rtools和rpy2

时间:2017-12-22 14:47:16

标签: python r rpy2

这是我的设置。我使用./configure --enable-R-shlib --enable-R-static-lib --enable-BLAS-shlib --prefix=/home/fpinto然后make && make install从源代码安装了R-3.2.0。那是因为我没有root权限。之后,我从源代码安装了python-2.7.14,从源代码安装了setuptools-38.2.4和pip-9.0.1。一切都被假设为好,我可以使用python2 -m pip install在本地安装任何包。最后,我用最后一个命令安装了rtools。

但是,当我尝试导入rtools时,输出是

Python 2.7.14 (default, Dec 20 2017, 01:10:08) 
[GCC 5.3.1 20160406 (Red Hat 5.3.1-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rtools
/home/fpinto/lib/python2.7/site-packages/rpy2-2.8.6-py2.7-linux-x86_64.egg/rpy2/rinterface/__init__.py:186: RRuntimeWarning: Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/fpinto/lib64/R/library/stats/libs/stats.so':
  libRlapack.so: cannot open shared object file: No such file or directory

  warnings.warn(x, RRuntimeWarning)
/home/fpinto/lib/python2.7/site-packages/rpy2-2.8.6-py2.7-linux-x86_64.egg/rpy2/rinterface/__init__.py:186: RRuntimeWarning: During startup - 
  warnings.warn(x, RRuntimeWarning)
/home/fpinto/lib/python2.7/site-packages/rpy2-2.8.6-py2.7-linux-x86_64.egg/rpy2/rinterface/__init__.py:186: RRuntimeWarning: Warning message:
  warnings.warn(x, RRuntimeWarning)
/home/fpinto/lib/python2.7/site-packages/rpy2-2.8.6-py2.7-linux-x86_64.egg/rpy2/rinterface/__init__.py:186: RRuntimeWarning: package ‘stats’ in options("defaultPackages") was not found 
  warnings.warn(x, RRuntimeWarning)`

正在寻找解决方案,人们发布了以R CMD ldd /home/fpinto/lib64/R/library/stats/libs/stats.so查找输出:

linux-vdso.so.1 =>  (0x00007ffd56bd1000)
libRlapack.so => /home/fpinto/lib64/R/lib/libRlapack.so (0x00007f509d1fe000)
libRblas.so => /home/fpinto/lib64/R/lib/libRblas.so (0x00007f509cfd0000)
libgfortran.so.3 => /usr/lib64/libgfortran.so.3 (0x00007f509cc93000)
libm.so.6 => /usr/lib64/libm.so.6 (0x00007f509c991000)
libquadmath.so.0 => /usr/lib64/libquadmath.so.0 (0x00007f509c754000)
libR.so => /home/fpinto/lib64/R/lib/libR.so (0x00007f509c19a000)
libgomp.so.1 => /usr/lib64/libgomp.so.1 (0x00007f509bf74000)
libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007f509bd57000)
libc.so.6 => /usr/lib64/libc.so.6 (0x00007f509b996000)
libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007f509b780000)
/lib64/ld-linux-x86-64.so.2 (0x00007f509d861000)
libreadline.so.6 => /usr/lib64/libreadline.so.6 (0x00007f509b539000)
libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f509b2d8000)
liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007f509b0b2000)
libbz2.so.1 => /usr/lib64/libbz2.so.1 (0x00007f509aea1000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00007f509ac8b000)
librt.so.1 => /usr/lib64/librt.so.1 (0x00007f509aa83000)
libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007f509a87e000)
libicuuc.so.50 => /usr/lib64/libicuuc.so.50 (0x00007f509a505000)
libicui18n.so.50 => /usr/lib64/libicui18n.so.50 (0x00007f509a107000)
libtinfo.so.5 => /usr/lib64/libtinfo.so.5 (0x00007f5099edc000)
libicudata.so.50 => /usr/lib64/libicudata.so.50 (0x00007f5098908000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f50985ff000)

你能帮我弄清楚发生了什么吗?

1 个答案:

答案 0 :(得分:0)

使用--enable-R-shlib --enable-BLAS-shlib --enable-LAPACK-shlib --prefix=$HOME/R-3.2.0 && make && make install再次配置R.

然后我从源配置./configure --prefix=$HOME/python-2.7.14 && make && make install安装了python2.7和python3.6。最后,使用源tar或pip安装了python包。