2016-01-06 34 views
2

我正在使用R 2.7.2和python 2.6.6並在centos 6.7上下載了rpy2-2.7.6。我正嘗試使用多種方式在centos上安裝ryp2。錯誤:試圖猜測R的HOME,但在路徑上沒有命令(R)centos

  1. python setup.py build --r-home=/usr/lib64/R/lib install
  2. pip install ryp2

越來越常見的錯誤:

Error: Tried to guess R's HOME but no command (R) in the PATH " . 

除了這個我還添加了PATH以及具有R_HOME和R bin路徑的LD_LIBRARY_PATH在.bashrc

仍然有相同的錯誤。請幫我解決這個問題。

回答

2

以下工作在RHEL6上,它仍在運行Python 2.6。爲了讓rpy2安裝腳本找到R,我們需要從Python 2.7複製一些代碼到rpy2的安裝文件中。
運行

pip install rpy2 

其未能按你的描述後,輸出告訴我們到哪裏尋找下載的代碼(例如/ tmp目錄/ PIP-集結meuser/rpy2 /)

訪問該文件夾,編輯setup.py 第一個「高清」行前添加以下代碼:

import subprocess 

if "check_output" not in dir(subprocess): # duck punch it in! 
    def f(*popenargs, **kwargs): 
     if 'stdout' in kwargs: 
      raise ValueError('stdout argument not allowed, it will be overridden.') 
     process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) 
     output, unused_err = process.communicate() 
     retcode = process.poll() 
     if retcode: 
      cmd = kwargs.get("args") 
      if cmd is None: 
       cmd = popenargs[0] 
      raise subprocess.CalledProcessError(retcode, cmd) 
     return output 
    subprocess.check_output = f 

保存文件。現在再次嘗試你的pip安裝行;它應該工作。

以供參考,該源從https://hg.python.org/cpython/file/d37f963394aa/Lib/subprocess.py#l544 來了,解決的辦法是從一個類似的問題,subprocess.check_output() doesn't seem to exist (Python 2.6.5)

如果你碰巧沒有root訪問的服務器上運行,則可能反而可以使用安裝命令

pip install --upgrade -v --user rpy2 

將最新的rpy2安裝到您的本地(用戶)帳戶中。其他一切都是一樣的。

+0

我有同樣的問題,並希望以應用解決方案。但是,在錯誤行中報告的那個目錄在創建後立即被刪除。任何方法來克服這一點? – splinter

+0

對不起。我從RHEL轉移了。其他人可以幫忙嗎?儘管Ctrl-z會中斷/暫停點進程...(鍵入「fg」來恢復它) – CPBL

0

爲什麼要使用PIP,而你可以按照如下安裝包:

sudo apt-get update 

sudo apt-get install python-rpy2 
相關問題