【问题标题】:Unable to install R package in Ubuntu 11.04 [closed]无法在 Ubuntu 11.04 中安装 R 包 [关闭]
【发布时间】:2011-12-07 14:28:16
【问题描述】:

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

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

谁能给我一些建议?

【问题讨论】:

  • 安装xml2-config?
  • 这个问题在 Ubuntu 14.04 中(再次)帮助了我
  • 我不知道这个问题是否离题,但下面的答案也解决了我使用 Ubuntu Trusty Tahr 的问题。
  • 应该将其移至 AskUbuntu 堆栈吗?这是一个与使用 R 或 RStudio 有关的问题(尽管它可能与其他软件一起出现?),这是由于 Ubuntu 中缺少所需的软件包造成的。根据我在右侧看到的“相关”列表,这似乎是一个很常见的问题。可以正确地问为什么 Ubuntu 缺少这些软件包?
  • @rickHenderson 它对其他 Linux 发行版也很有用。

标签: xml r ubuntu installation


【解决方案1】:

install.packages 方法

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

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 包。如果您使用的是 ubuntu 的 LTS 版本,这可能很重要。

【讨论】:

  • 你可以试试突触吗?在那里寻找你需要的包裹
  • r-cran-xml不够用,还得做libxml2-dev
  • 分享我对可能对 MAC 用户有帮助的类似问题的观察。即使我拥有所有依赖库,我仍然遇到错误。经过大量试验后,这救了我——在使用 install.packages() 通过 rstudio 安装时,你会收到一个提示询问——你想从源代码安装需要编译的包吗? y/n:在此处将您的回答设为“n”。这对我有用。
  • 在 Debian 中仅使用 sudo apt-get install libxml2-dev 就足够了
  • 我收到此错误:sudo apt-get install r-cran-xml
【解决方案2】:

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

 sudo apt-get install r-cran-xml

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

【讨论】:

    猜你喜欢
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-02
    • 2012-08-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    相关资源
    最近更新 更多