致命错误:Rdefines.h:没有那个文件或目录

致命错误: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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值