13

I've seen a lot of posts here and elsewhere about this error, but none of the proposed solutions appear to be relevant. I'm on Python 2.7.9, I have an R executable in my path, and I'm trying to install it on an RHEL server not on Windows.

Here's the specific error I'm seeing. Does anybody have any idea what would be causing it or how to fix it? Thanks!

$ pip install rpy2
Downloading/unpacking rpy2
  Downloading rpy2-2.5.6.tar.gz (165kB): 165kB downloaded
  Running setup.py (path:/tmp/pip_build_my520/rpy2/setup.py) egg_info for package rpy2
    Error: Tried to guess R's HOME but no R command in the PATH.
    Complete output from command python setup.py egg_info:
    Error: Tried to guess R's HOME but no R command in the PATH.
Matt Stone
  • 185
  • 1
  • 1
  • 8
  • So, where did you install R (and what does your python session see as the $PATH)? (I think rpy2 is just an interface package but I only see rpy2 question on SO through the R side of the looking-glass.) There are many instances of R users getting confused because the "system" path is not necessarily the same path as seen from within an R session. – IRTFM May 06 '15 at 17:04
  • Yeah, I've had it installed. I'm on a HPC cluster right now and I switched to a different environment module (R 3.0.2 instead of R 3.0.0) and that fixed it. Not entirely sure why, but I'll take it. – Matt Stone May 06 '15 at 17:11
  • http://stackoverflow.com/questions/4924917/trouble-installing-rpy2-on-win7-r-2-12-python-2-5 –  Nov 11 '15 at 15:49

2 Answers2

19

Download the rpy2‑2.7.5‑cp35‑none‑win_amd64.whl file from Christoph Gohlke's Python Extension Packages for Windows repository here. Using the command line, change to the download folder and run:

pip install rpy2‑2.5.5‑cp34‑none‑win_amd64.whl

This should solve the R directory issue and rpy2 should install nicely. All credit to MattDMo.

Community
  • 1
  • 1
Peter Maguire
  • 391
  • 4
  • 7
  • 2
    Just wanted to add: if cp34 didn't work, try download rpy2-2.7.8-cp27-none-win_amd64.whl if you use python27. – Ruby May 05 '17 at 03:21
  • I am getting a similar error on Heroku and I can't figure how to apply this on Heroku. In my case when Heroku get to the line for installing rpy2 in my requirements file, it goes to the following link for downloading rpy2 and then produces the error. https://files.pythonhosted.org/packages/02/d1/074ffbbe7b4bf74c60b75d74c8e67a1e4515b0d85f85cd6540e39610754a/rpy2-2.9.5.tar.gz – Sher Afghan May 23 '19 at 06:28
0

This issue available in lower version rpy2. After installing the below version, it has been resolved.

rpy2==3.4.2
Sathiamoorthy
  • 8,831
  • 9
  • 65
  • 77