致命错误:Rdefines.h:没有那个文件或目录
Rdefines.h: No such file or directory
关键词
- CentOS 7
- 安装rpy2
- pip3 install rpy2报错
- python3 setup.py rpy2报错
错误
- 致命错误:Rdefines.h:没有那个文件或目录
- Rdefines.h: No such file or directory
- 报错代码如下
running build_clib
building 'r_utils' library
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/rpy
creating build/temp.linux-x86_64-3.6/rpy/rinterface
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I./rpy/rinterface -c ./rpy/rinterface/r_utils.c -o build/temp.linux-x86_64-3.6/./rpy/rinterface/r_utils.o
./rpy/rinterface/r_utils.c:24:22: 致命错误:Rdefines.h:没有那个文件或目录
#include <Rdefines.h>
解决方案
打开r_utils.c文件(…/rpy2-2.9.3/rpy/rinterface/r_utils.c)
起始行如下:
#include <stdlib.h>
#include <Rdefines.h>
#include <R_ext/Rallocators.h>
#include "r_utils.h"
static int embeddedR_isinitialized;
/* Return whether R has been initialized */
int
rpy2_isinitialized(void)
{
int res = (embeddedR_isinitialized == 1) ? 1 : 0;
return res;
}
仔细找寻文件可以发现,Rdefines.h、R_ext/Rallocators.h等等文件都是存在的。
他们的路径为:
/usr/local/lib64/R/include/
如:
- Rdefines.h:
/usr/local/lib64/R/include/Rdefines.h
- R_ext/Rallocators.h:
/usr/local/lib64/R/include/R_ext/Rallocators.h
而 CentOS 7默认的c头文件库路劲为:
/usr/include/
因此,最便捷的解决方式就是:
[进入root]
$ su
[直接复制需要的文件到主目录]
# cp -r /usr/local/lib64/R/include/* /usr/include/
[退出root]
# exit
$ pip3 install rpy2
[ 或者从源码安装 rpy2 ]
$ python3 setup.py install