我在
中自定义安装了R〜/ R-3.2.2 / bin中/
当我跑步时
sudo pip install rpy2
我得到了
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
我找不到这个问题的答案,即使它出现在几个帖子中。这是我试过的
将R可执行文件添加到PATH
export PATH = $ PATH:/home/R-3.2.2/bin/ 没用?
使用相同的值导出R_HOME:无法正常工作
echo export PATH=$PATH:/home/R-3.2.2/bin/ >> ~/.bashrc
source ~/.bashrc
没用。
另一方面,“问题”似乎在这里解决了 https://bitbucket.org/rpy2/rpy2/issues/283/rpy2-installation-error-when-r-output
如何正确安装rpy2?
答案 0 :(得分:1)
错误是因为issue in rpy2(刚刚修复)。 否则,可能是因为R不是你想象中的PATH,或者你可能没有运行它的权限。
尝试:
# 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