Tried to guess R's HOME but no R command in the PATH. OsX 10.6

20,216

Solution 1

Make sure you have R installed

brew install r

Then install rpy

pip install rpy2

Solution 2

The rpy2 code is doing the wrong check. R might be perfectly fine, but rpy2 is using an unreliable check.

To check for R, the rpy2 uses subprocess.check_output. However, that was introduced (AFAIK) in python 2.7.

If you're using a version of python less than 2.7 then you should update to at least 2.7.

If you must use python 2.6, then you should look at this answer to see how to force subprocess.check_output into python 2.6, finally allowed you to install rpy2. This is what I had to do as I was unable to update the version of python.

Download the rpy2 code, and edit its setup.py and insert the code from that answer.

Solution 3

  1. use easy_install rpy2 and it works just fine.

http://rpy.sourceforge.net/rpy2/doc-2.2/html/overview.html#download

Make sure you have setuptools installed.

If you do not know how to do that, check this link

You can just run ez_setup.py and let it decide for you.

  1. Add C:\Program Files\R\R-2.12.1\bin\i386 (the path to R.dll) to the environment variable PATH

  2. Add an environment variable R_HOME with C:\Program Files\R\R-2.12.1

  3. Add an environment variable R_USER with your Windows username

Share:
20,216
user2988577
Author by

user2988577

Updated on August 09, 2022

Comments

  • user2988577
    user2988577 almost 2 years

    I am trying to install rpy2 and I am facing a common issue. Unfortunately all the solution I have found are for win7

    I have installed a Python 2.7 and R 2.15. then I write on the terminal

    easy_install rpy2
    

    or, alternatively

    pip install rpy2
    

    Same result:

    Tried to guess R's HOME but no R command in the PATH
    

    What I should do?

  • Aaron McDaid
    Aaron McDaid over 7 years
    @dww, updating python would also resolve this. That's the easiest solution of course! But I forgot about that because I don't have control of the server that I use and can't update the system-wide python. I'll edit my answer