2011-10-14 98 views
104

我是Linux和R的新手。無法在Ubuntu中安裝R軟件包11.04

我在Ubuntu 11.04中安裝了R 2.12。今天,我試圖安裝一個新的包,所以我跑以下命令:

install.packages('XML') 

但安裝失敗,給了以下信息:

* installing *source* package ‘XML’ ... 
checking for gcc... gcc 
checking for C compiler default output file name... a.out 
checking whether the C compiler works... yes 
checking whether we are cross compiling... no 
checking for suffix of executables... 
checking for suffix of object files... o 
checking whether we are using the GNU C compiler... yes 
checking whether gcc accepts -g... yes 
checking for gcc option to accept ISO C89... none needed 
checking how to run the C preprocessor... gcc -E 
No ability to remove finalizers on externalptr objects in this verison of R 
checking for sed... /bin/sed 
checking for pkg-config... /usr/bin/pkg-config 
checking for xml2-config... no 
Cannot find xml2-config 
ERROR: configuration failed for package ‘XML’ 
* removing ‘/home/spirit/R/i686-pc-linux-gnu-library/2.12/XML’ 

The downloaded packages are in 
    ‘/tmp/RtmpoZYxnv/downloaded_packages’ 
Warning message: 
In install.packages("XML") : 
    installation of package 'XML' had non-zero exit status 

我也試過:

sudo install.packages('XML') 

但它給出了相同的錯誤信息。

任何人都可以給我任何建議?提前致謝。

+0

安裝'xml2-config'? –

+30

@WayneWerner對於(有用的)解決方案給出2年後關閉(有用!)問題並不感到羞恥嗎?併發布像你這樣的評論甚至沒有閱讀後者... – user14764

+7

這個問題剛剛幫助我(再次)在Ubuntu 14.04 – geneorama

回答

161

的install.packages方法

您需要安裝Ubuntu的軟件包libxml2-dev所以在shell提示下鍵入:

sudo apt-get update 
sudo apt-get install libxml2-dev 

你需要爲這個特殊的sudo權力。

Ubuntu的軟件包方法

正如裏奇和德克所提到的,你也可以使用:

sudo apt-get install r-cran-xml 

如果你走這條路,我會建議您檢查出R ubuntu sources頁面,它將確保您擁有當前版本的R和相關的R軟件包。如果您使用的是LTS版本的ubuntu,這可能很重要。

+1

你可以嘗試突觸嗎?尋找你需要的軟件包 – pacomet

+0

r-cran-xml是不夠的,只好做libxml2-dev – Ferroao

27

由Colin答案是在狹義上是正確的,但在同一時間錯了,因爲你可以說

sudo apt-get install r-cran-xml 

如XML是在Ubuntu提供的CRAN軟件包之一。 apt-cache search r-cran-*確實看到其他人。