rpy2 找不到包含目录
rpy2 not finding include directory
在使用命令安装 rpy2 包时:python setup.py build install ,安装过程抛出以下错误。
我配置了两个环境变量,指向丢失的文件。
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 进程的配置以找到包含 headers。
输出中的关键提示是:
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)。
我是这样工作的:
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版本号
在使用命令安装 rpy2 包时:python setup.py build install ,安装过程抛出以下错误。
我配置了两个环境变量,指向丢失的文件。
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 进程的配置以找到包含 headers。
输出中的关键提示是:
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)。
我是这样工作的:
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版本号