"非零退出状态" R 3.0.1中的 'XML' 和 'RCurl'涉及的一个问题标题。

76

我在我的Ubuntu 13.10机器上安装XML和RCurl时遇到了一些麻烦。我今天执行了所有sudo更新和升级。

我试图使用rattle for R,但无法安装'rattle'所需的'XML'。这与一年前提出的相同的问题,只是操作系统不同。以下是我收到的错误消息:

> install.packages("RCurl")
Installing package into ‘/home/steven/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RCurl_1.95-4.1.tar.gz'
Content type 'application/x-gzip' length 870915 bytes (850 Kb)
opened URL
==================================================
downloaded 850 Kb

* installing *source* package ‘RCurl’ ...
** package ‘RCurl’ successfully unpacked and MD5 sums checked
checking for curl-config... no
Cannot find curl-config
ERROR: configuration failed for package ‘RCurl’
* removing ‘/home/steven/R/x86_64-pc-linux-gnu-library/3.0/RCurl’
Warning in install.packages :
  installation of package ‘RCurl’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpUwBkbS/downloaded_packages’
> install.packages("XML")
Installing package into ‘/home/steven/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/XML_3.98-1.1.tar.gz'
Content type 'application/x-gzip' length 1582216 bytes (1.5 Mb)
opened URL
==================================================
downloaded 1.5 Mb

* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... 
rm: cannot remove 'a.out.dSYM': Is a directory
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
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/steven/R/x86_64-pc-linux-gnu-library/3.0/XML’
Warning in install.packages :
  installation of package ‘XML’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpUwBkbS/downloaded_packages’

不太确定从这里如何继续。


13
你在Linux上安装了curl和xml吗?运行以下命令:sudo apt-get install libcurl4-openssl-devsudo apt-get install libxml2-dev - jdharrison
安装R的开发库非常重要。你可能没有选择这个选项(而且你还选择了安装一个过时的版本)。 - IRTFM
@jdharrison 我还没有尝试过那些命令,今晚回家后我会试一下。 - MCP_infiltrator
@IShouldBuyABoat 我不知道我需要安装 R 的开发库。当我从 13.04 升级到 13.01 的 Ubuntu 时,我安装了 3.0.1 版本,我只是从软件中心安装的。 - MCP_infiltrator
@jdharrison解决了这个问题,所以您可以将其列为答案,我会接受它,谢谢。 - MCP_infiltrator
4个回答

133
在Ubuntu上安装curl和xml,请运行:

sudo apt-get install curl libxml2-dev

sudo apt-get install libcurl4-openssl-dev libxml2-dev

在R中安装软件包时出现的错误信息表明curl和xml库不存在或无法找到。


或者libcurl4-gnutls-dev可以作为libcurl4-openssl-dev的替代品。另请参见http://askubuntu.com/a/428379/17060。 - michael
我正在WSL上运行Ubuntu 16.04的R,这个在bash提示符下的命令解决了我的问题:apt-get install libssl-dev - Bhail

29
在 CentOS 6+ 中,您可以使用以下方法进行操作
sudo yum -y install curl
sudo yum -y install libcurl libcurl-devel
sudo yum -y install libxml2 libxml2-devel

9
您需要运行命令 sudo yum -y install libxml2 libxml2-devel 安装libxml2和libxml2-devel。 - xbsd
当我安装"h2o"时,前两个命令就足够了。 - Bas

2
对于那些无法使用yumapt-get安装的人,我分享一下我的经验:
我通过下载源代码并编译来自己安装了libcurl-openssl-dev。即便如此,我仍然遇到了找不到curl-config的问题...直到查看了RCurl源代码并看到引用了CURL_CONFIG环境变量,我才知道该怎么办。我尝试在我的.bashrc中设置它,它似乎起作用了: export CURL_CONFIG=~/my/libcurl/curl-config

0

对于Ubuntu 18.05,有时存储库会出现问题,请按照以下步骤运行:

在sudo编辑的行中添加以下存储库

deb http://security.ubuntu.com/ubuntu bionic-security main

sudoedit /etc/apt/sources.list 
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev --fix-broken
sudo apt-get install libcurl4-openssl-dev libxml2-dev

修复包名


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接