Install rpy2 with custom R installation

孤者浪人 提交于 2019-12-11 10:55:05

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/37498145/install-rpy2-with-custom-r-installation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!