2016-11-29 29 views
0

我試圖在我的MacBook Air,Yosemite上安裝RPY2,而且我幾乎按照以下website的指示進行安裝。更具體地講,我:安裝RPy2 for MacOS:將R解釋器的目錄添加到PATH環境變量

  • 安裝[R 3.3.2
  • 使用pip install rpy2安裝Rpy2,由RPY2網站
  • 設置R_HOME變量到R主目錄
    echo 'R_HOME="/Library/Frameworks/R.framework/Versions/3.3/Resources"; export R_HOME' >> ~/.bashrc
建議

但是,當我測試這是否適用於Python與
from rpy2.rinterface import R_VERSION_BUILD 我得到的錯誤:

Traceback (most recent call last): 
    File "<pyshell#3>", line 1, in <module> 
    from rpy2.rinterface import R_VERSION_BUILD 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rpy2/rinterface/__init__.py", line 81, in <module> 
    """) 
RuntimeError: The R home directory could not be determined. 

    Try to install R <https://www.r-project.org/>, 
    set the R_HOME environment variable to the R home directory, or 
    add the directory of the R interpreter to the PATH environment variable. 

我是否確實需要add the directory of the R interpreter to the PATH environment variable,如果是這樣,我會怎麼做呢?

回答

0

當您修改您的~/.bashrc後,您可能需要註銷並重新登錄才能更改終端環境。

否則,一個增加了R鍵這樣的路徑:

export PATH=/directory/where/the/R/executable/is:${PATH} 

最後,我不會建議一個使用該系統的Python的(除非在暴殄天物設置這樣的容器)。考慮使用homebrew,並安裝Python和R。

+0

嗨@lgautier,謝謝你的建議。我會立即測試它。關於下載Python,我從www.python.org本身下載了它。那還行嗎? –

+0

這很好,我認爲(Mac擁有者可以確認)。重要的部分是建議離開系統的Python。 – lgautier

+0

我嘗試過三種方式(指向三種不同的R可執行文件),但仍然沒有運氣。即使重新啓動計算機後,我也會得到相同的錯誤。我檢查過重啓後設置了PATH。你有沒有其他建議? –

相關問題