Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
609 views
in Technique[技术] by (71.8m points)

python - Getting Segmentation fault Core dumped error while importing robjects from rpy2

Installed R and rpy2 manually

Installation is successful but getting the above mentioned error. Please help me out?

Outputs of some useful commands:

>>> import rpy2
>>> rpy2.__path__
['/home/ashish/miniconda2/lib/python2.7/site-packages/rpy2-2.8.2-py2.7-linux-x86_64.egg/rpy2']
>>> import rpy2.robjects
cannot find system Renviron
/home/ashish/miniconda2/lib/python2.7/site-packages/rpy2-2.8.2-py2.7-linux- x86_64.egg/rpy2/rinterface/__init__.py:185: RRuntimeWarning: Fatal error: unable to open the base package


warnings.warn(x, RRuntimeWarning)
Segmentation fault (core dumped)

Thanks in advance..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you install rpy2 via conda, and also have a system installation of R on the same machine (e.g with RStudio), the system's R installation will be used. Since this R version doesn't match the one that rpy2 needs, segmentation faults occur.

1) remove any existing system installations of R (see here). Verify that you don't have any installations of R:

$>which R
R not found

2) define R_HOME env variable, either in your .rc file:

export R_HOME=/Users/<your user>/anaconda3/envs/<env name>/lib/R

or dynamically in the python project:

import os
os.environ['R_HOME'] = '/Users/<your user>/anaconda3/envs/<env name>/lib/R'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...