3

I've recently switched from Windows to OSX. I have some scripts that use rpy2 that I have been unable to get working on OSX and I'm not sure how to troubleshoot any further. I've seen several other similar questions with the same segmentation fault error but most of them do not have accepted answers.

I use Anaconda(technically, miniconda) as a package manager and have installed R 3.3.2. The version of rpy2 I'm using is 2.8.5. I've installed Python (2.7.13) separately from a download from Python site so there's that separately from the miniconda version.

I use PyCharm as my IDE and I'm not 100% certain that the correct python executable is being used (I've read not to use the pre-installed mac one) but my python console shows "Continuum Analytics" so I don't thinks that's the problem. I've configured my interpreter to use the binary from the conda environment I setup for my project.

Here is the smallest amount of code that recreates the error...

These all work without an issue:

import rpy2
import rpy2.rinterface
import rpy2.rlike

All of these throw an error:

import rpy2.robjects
import rpy2.interactive
import rpy2.ipython

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
Dave Novelli
  • 2,086
  • 4
  • 32
  • 42
  • Do all those three imports throw the same error? – Alex Luis Arias Feb 25 '17 at 22:18
  • How did you install Python and R? Did you use brew? – Alex Luis Arias Feb 25 '17 at 22:36
  • They all throw the same error. I installed miniconda which installs python. I also separately installed python with the installer from the python website. I installed R directly from the installer downloaded from the R website – Dave Novelli Feb 26 '17 at 22:37
  • [issue resolved - see here](https://stackoverflow.com/questions/39347782/getting-segmentation-fault-core-dumped-error-while-importing-robjects-from-rpy2/53639407#53639407) - the problem is due to installations of R (standalone) and conda on the same machine – Eitan Rousso Dec 05 '18 at 19:30

2 Answers2

0

Sounds like a problem with installation. Try installing rpy2 with

pip install rpy2
farghal
  • 281
  • 1
  • 5
0

I changed R_HOME in my conda environment and it did the trick :

export R_HOME=/Users/<username>/anaconda3/envs/<env>/lib/R