xml 无法在 Ubuntu 11.04 中安装 R 包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7765429/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 14:59:19  来源:igfitidea点击:

Unable to install R package in Ubuntu 11.04

xmlrubuntuinstallation

提问by Derrick Zhang

I'm new to Linux and R.

我是 Linux 和 R 的新手。

I installed R 2.12 in Ubuntu 11.04. Today I tried to install a new package, so I ran the following command:

我在 Ubuntu 11.04 中安装了 R 2.12。今天我尝试安装一个新包,所以我运行了以下命令:

install.packages('XML')

But the installation failed and gave the following information:

但是安装失败并给出以下信息:

* 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

I also tried:

我也试过:

sudo install.packages('XML')

But it gives the same error information.

但它给出了相同的错误信息。

Anyone can give me any advice?

任何人都可以给我任何建议吗?

回答by csgillespie

The install.packages method

install.packages 方法

You need to install the ubuntu package libxml2-devSo in a shell prompt type:

你需要安装 ubuntu 包libxml2-dev所以在 shell 提示下输入:

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

You will need special sudopowers for this.

sudo为此,您将需要特殊的权力。

Ubuntu package method

Ubuntu打包方法

As Richie and Dirk mentioned, you can also use:

正如 Richie 和 Dirk 提到的,您还可以使用:

sudo apt-get install r-cran-xml

If you go down this path, I would recommend that you check out the R ubuntu sourcespage which will ensure you have a current version of R and the associated R packages. This could be important if you are using the LTS version of ubuntu.

如果您沿着这条路走下去,我建议您查看R ubuntu 源页面,这将确保您拥有当前版本的 R 和相关的 R 包。如果您使用的是 ubuntu 的 LTS 版本,这可能很重要。

回答by Dirk Eddelbuettel

The answer by Colin is correct in a narrow sense, but at the same time wrong as you can just say

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

 sudo apt-get install r-cran-xml

as XML is one of the CRAN packages available in Ubuntu. Do apt-cache search r-cran-*do see the others.

因为 XML 是 Ubuntu 中可用的 CRAN 包之一。这样做apt-cache search r-cran-*确实看到了别人。