user2988577
user2988577

Reputation: 4207

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

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?

Upvotes: 10

Views: 20342

Answers (5)

louis_guitton
louis_guitton

Reputation: 5677

Make sure you have R installed

brew install r

Then install rpy

pip install rpy2

Upvotes: 4

moiaussi06
moiaussi06

Reputation: 221

  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

Upvotes: 1

Aaron McDaid
Aaron McDaid

Reputation: 27133

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.

Upvotes: 2

user5240180
user5240180

Reputation:

I had the same problem (on a Mac) and none of the solutions I found online worked. The only thing that worked for me was:

conda update python

pip install rpy2

Upvotes: 1

DavidArndt
DavidArndt

Reputation: 446

Installation worked for me when I did

pip install rpy2

but not when I did

sudo pip install rpy2

So in case you were using sudo and not mentioning it, this might help you. I also tried manually installing from source, which worked when I used just 'python setup.py install' for the install step, but not with sudo!

I did this on CentOS 7 with Python 2.7 and R 3.2 (as the root user). On sudo's behavior, see this question.

Upvotes: 0

Related Questions