Peter
Peter

Reputation: 93

Install rpy2 with custom R installation

I have a custom installation of R in

~/R-3.2.2/bin/

When I run

sudo pip install rpy2

I get

    Warning: Tried to guess R's HOME but no command (R) in the PATH.
Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "/tmp/pip-build-ITKmkR/rpy2/setup.py", line 330, in <module>
    ri_ext = getRinterface_ext()
  File "/tmp/pip-build-ITKmkR/rpy2/setup.py", line 231, in getRinterface_ext
    r_home = _get_r_home()
  File "/tmp/pip-build-ITKmkR/rpy2/setup.py", line 63, in _get_r_home
    r_home = r_home.split(os.linesep)
UnboundLocalError: local variable 'r_home' referenced before assignment

I have found no answer to this problem, even though it appears in several posts. Here is what I tried

did not work.

On the other hand the "problem" seems solved here https://bitbucket.org/rpy2/rpy2/issues/283/rpy2-installation-error-when-r-output

How to install rpy2 correctly?

Upvotes: 3

Views: 2338

Answers (1)

lgautier
lgautier

Reputation: 11565

The error is because of an issue in rpy2 (just fixed). Otherwise, it might be because R is either not in the PATH as you think it is, or may be you do not have the permission to run it.

Try:

# assert that the R executable is where you think it is
~/R-3.2.2/bin/R --version
# set the PATH
export PATH=${PATH}:~/R-3.2.2/bin/
# unset R_HOME if needed
unset R_HOME
# install rpy2
pip install rpy2

Upvotes: 2

Related Questions