Why won't Rpy2 install on my OSX Sierra terminal?

I've seen many different people post this issue (example: Tried to guess R HOME but not R command in PATH. OsX 10.6 and Installing rpy2 on Mac OSX 10.8.5 ), but I have yet to find a viable solution.

I realized that I had Python-2.7 installed in my terminal, and since I had recently updated RStudio, I thought my R was also updated. But every time I tried to run:

pip install rpy2

      

or

easy_install rpy2

      

I kept getting the same error Error: Tried to guess R HOME but no command 'R' in the PATH

.

After doing some googling, I decided to try downloading the latest version of R (v 3.4.1), although I'm pretty sure it was already updated to begin with. But now I am getting the following error behemoth (I should note that I compressed it):

In file included from ./rpy/rinterface/_rinterface.c:122:
    ./rpy/rinterface/sequence.c:2173:1: warning: unused function 'ComplexVectorSexp_AsSexp' [-Wunused-function]
    ComplexVectorSexp_AsSexp(PyObject *pyfloat) {
    ^
    11 warnings generated.
    cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.12-intel-2.7/./rpy/rinterface/_rinterface.o -L/usr/local/lib -Lbuild/temp.macosx-10.12-intel-2.7 -L/usr/local/lib -lpcre -llzma -lbz2 -lz -licucore -lm -liconv -lr_utils -o build/lib.macosx-10.12-intel-2.7/rpy2/rinterface/_rinterface.so -fopenmp -F/Library/Frameworks/R.framework/.. -framework R
    clang: error: unsupported option '-fopenmp'
    clang: error: unsupported option '-fopenmp'
    error: command 'cc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-zT8DaX/rpy2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-bDnbE5-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-zT8DaX/rpy2/

      

So now I have a completely different error. I thought that updating my R would automatically add it to my PATH environment variable, but now I'm really at a loss as to how to deal with it. I tried google this new error, but I can't find any solutions aimed at installing Rpy2 on Mac OSX with Python-2.7 and R-3.4. Can anyone suggest any advice?

ADDITION

I have now tried many other approaches, including downloading the XCODE and updating my GCC compiler (one such approach is indicated at http://cs.millersville.edu/~gzoppetti/InstallingGccMac.html ) and I also tried reinstalling GCC using the command brew reinstall gcc --without-multilib

. I also edited my PATH environment variables to include R, CC and so far no luck.

+3


source to share


3 answers


Now I realized that rpy2 installation depends on the correct type of compiler being used. The default compiler for Apple is clang, which does not support the rpy2 configuration process. So, after acquiring the gcc compiler with homebrew, you can run brew ls gcc

to see the file paths which gcc compilers are present on your computer. Then I ran the following commands in a terminal to change the default compiler from clang to the gcc-7 file path, then set the appropriate flags (which I inferred from reading the error messages provided by the compiler earlier) and then install rpy2.

export CC=/usr/local/Cellar/gcc/7.2.0/bin/x86_64-apple-darwin16.7.0-gcc-7
export CFLAGS="-W"
pip install rpy2==2.8.6

      



It should be noted that I installed rpy2 version 2.8.6 since my scripts are in Python 2.7 and rpy2 2.9.0 is only compatible with Python 3.x. Also, I know this answer may not adequately describe the problem for everyone, so I recommend that other users expand and / or fix this solution.

0


source


The "no R in PATH" error is exactly what it says. To play, open a terminal and type "R": no such command should be found. The solution is to find R in PATH .



Now, starting with R-3.4, the tools needed to compile R and R extensions to C have changed and the requirements were less standard than one might have hoped. This can be discussed as a problem with R and OS X, and there is an issue with the rpy2 tracker about it .

+1


source


It is possible to use the GCC switch with a single command env

:

env CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7 pip install rpy2

      

The reason clang doesn't work with RPy2 is because clang 4.0.0 does not include the flag -fopenmp

that R is using. There's an ongoing stream of open file problems on this Bitbucket RPy2.

0


source







All Articles