rpy2找不到包含目录

问题描述 投票:2回答:2

在使用命令:python setup.py build install安装rpy2软件包时,安装过程将引发以下错误。

我已经配置了两个环境变量,指向丢失的文件。

export R_HOME=/data/myprojects/R/R-devel
export R_INCLUDE_DIR=/data/myprojects/R/R-devel/include

python setup.py build install
setup.py:29: UserWarning: R emitting a warning: WARNING: ignoring environment value of R_HOME
  warnings.warn("R emitting a warning: %s" % r_home[0])
setup.py:130: UserWarning: R emitting a warning: WARNING: ignoring environment value of R_HOME
  warnings.warn("R emitting a warning: %s" % rversion)
R version 3.3.0 Patched (2016-05-05 r70590) -- "Supposedly Educational"
/data/myprojects/R/R-patched/bin/R CMD config --ldflags
R was not built as a library
setup.py:155: UserWarning: R emitting a warning: WARNING: ignoring environment value of R_HOME
  warnings.warn("R emitting a warning: %s" % output[0])
/data/myprojects/R/R-patched/bin/R CMD config --cppflags
R was not built as a library
setup.py:211: UserWarning: No include specified
  warnings.warn('No include specified')
setup.py:222: UserWarning: No libraries as -l arguments to the compiler.
  warnings.warn('No libraries as -l arguments to the compiler.')

    Compilation parameters for rpy2's C components:
        include_dirs    = []
        library_dirs    = []
        libraries       = []
        extra_link_args = []

running build
running build_py
running build_clib
building 'r_utils' library
gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -I./rpy/rinterface -c ./rpy/rinterface/r_utils.c -o build/temp.linux-s390x-2.7/./rpy/rinterface/r_utils.o
./rpy/rinterface/r_utils.c:31:22: fatal error: Rdefines.h: No such file or directory
 #include <Rdefines.h>
                      ^
compilation terminated.
error: command 'gcc' failed with exit status 1

问题:如何修复setup.py进程的配置以查找包含标头。

python r install rpy2
2个回答
2
投票

输出中的关键提示是:

R was not built as a library

R必须构建为共享库,以便rpy2能够使用该共享库(请参阅此处的注释:http://rpy2.readthedocs.io/en/version_2.7.x/overview.html#using-rpy2-with-other-versions-of-r-or-python)。


0
投票

我让它像这样工作:

cd rpy2-2.8.2
ln -s /usr/local/lib/R/include/* rpy/rinterface/

当然替换你的rpy2版本。您可以使用“R RHOME”命令找到包含的位置。更一般的是:

ln -s RHOME/include/* rpy2-X.X.X/rpy/rinterface/

在哪里填写RHOME路径和rpy2版本号。

© www.soinside.com 2019 - 2024. All rights reserved.