Reputation: 93
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
add the R executable to the PATH
export PATH=$PATH:/home/R-3.2.2/bin/ did not work
export R_HOME with the same value: did not work
echo export PATH=$PATH:/home/R-3.2.2/bin/ >> ~/.bashrc
source ~/.bashrc
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
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