2014-10-07 265 views
1

我試圖安裝R軟件包fGarch,但似乎有問題。我用下面的命令:安裝R軟件包時出錯fGarch

import rpy2.interactive as r 
import rpy2.interactive.packages 
rlib = r.packages.packages 
r.packages.importr("utils") 
package_name = "fGarch" 
rlib.utils.install_packages(package_name) 

安裝大多去罰款,除了在最後的警告:

/home/vdesai/anaconda/lib/python2.7/site-packages/rpy2/robjects/packages.py:216: UserWarning: Conflict when converting R symbol in the package "tools" to a Python symbol (package.dependencies -> package_dependencies while there is already package_dependencies) 
warn(msg) 

當我嘗試加載包:

%R library(fGarch) 

我得到以下錯誤:

Error in library(fGarch) : there is no package called ‘fGarch’ 
In addition: Warning messages: 
1: In (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos,  : 
installation of package ‘MASS’ had non-zero exit status 
2: In (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, : 
installation of package ‘fBasics’ had non-zero exit status 
3: In (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, : 
installation of package ‘fGarch’ had non-zero exit status 
Error in library(fGarch) : there is no package called ‘fGarch’ 

請注意,從Rstudio使用此軟件包不會造成任何困難。有人可以幫忙嗎?

回答

1

我找到了以下問題的答案。主要思想是1)安裝anaconda,它提供了一個很好的python發行版2)通過運行如下命令,通過conda安裝R:「conda install --channel https://conda.binstar.org/r r」3)通過運行「conda install --channel https://conda.binstar.org/r安裝rpy2 rpy2" 。

現在,如果您嘗試從ipython筆記本安裝fGarch,我曾經在安裝依賴MASS時出現錯誤。但是這些依賴關係可以在conda通道r中打包,我們可以使用命令安裝它們: conda install --channel https://conda.binstar.org/r r-mass conda install --channel https://conda.binstar.org/r r-fbasics 然後,您應該能夠安裝fGarch來自ipython筆記本。

這種方法的好處是,如果事情沒有按計劃進行,您總是可以刪除軟件包目錄或整個anaconda目錄。所以它很容易實驗。