当前位置: 首页>>技术教程>>正文


无法在Ubuntu 11.04中安装R包

, , ,

问题描述

我是Linux和R的新手。

我在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')

但它提供了相同的错误信息。

任何人都可以给我任何建议吗?提前致谢。

最佳解决思路

install.packages方法

你需要在shell提示符下安装ubuntu软件包libxml2-dev

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

您需要特殊的sudo功能。

Ubuntu包方法

正如Richie和Dirk所提到的,你也可以使用:

sudo apt-get install r-cran-xml

如果你走这条路,我建议你看一下R ubuntu sources页面,它确保你有一个当前版本的R和相关的R包。如果您使用的是UTSntu的LTS版本,这可能很重要。

次佳解决思路

科林的答案在狭义上是正确的,但同时你可以说是错误的

 sudo apt-get install r-cran-xml

因为XML是Ubuntu中可用的CRAN包之一。 apt-cache search r-cran-*会看到其他人。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/6839.html,未经允许,请勿转载。