无法在CentOS上的R中安装XML包

时间:2015-03-12 15:37:40

标签: r centos

当我尝试在CENTOS上的R中安装xml包时,我收到了这样的警告:

> install.packages("XML")
Installing package into ‘/opt/wpusers/r-mkosinski/R/x86_64-redhat-linux-gnu-library/3.1’
(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... /usr/bin/sed
checking for pkg-config... /bin/pkg-config
checking for xml2-config... no
Cannot find xml2-config
ERROR: configuration failed for package ‘XML’
* removing ‘/opt/wpusers/r-mkosinski/R/x86_64-redhat-linux-gnu-library/3.1/XML’
Warning in install.packages :
  installation of package ‘XML’ had non-zero exit status

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

>

我的会话信息是:

> session_info()
Session info --------------------------------------------------------------------
 setting  value                       
 version  R version 3.1.2 (2014-10-31)
 system   x86_64, linux-gnu           
 ui       RStudio (0.98.1091)         
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       Europe/Warsaw               

Packages ------------------------------------------------------------------------
 package    * version   date       source                            
 archivist    1.2       2015-02-12 Github (pbiecek/archivist@d5305be)
 assertthat * 0.1       2013-12-06 CRAN (R 3.1.2)                    
 bitops     * 1.0-6     2013-08-17 CRAN (R 3.1.2)                    
 DBI          0.3.1     2014-09-24 CRAN (R 3.1.2)                    
 devtools     1.7.0     2015-01-17 CRAN (R 3.1.2)                    
 digest     * 0.6.8     2014-12-31 CRAN (R 3.1.2)                    
 dplyr        0.4.0     2015-01-08 CRAN (R 3.1.2)                    
 htmltools  * 0.2.6     2014-09-08 CRAN (R 3.1.2)                    
 httpuv     * 1.3.2     2014-10-23 CRAN (R 3.1.2)                    
 httr       * 0.6.1     2015-01-01 CRAN (R 3.1.2)                    
 lubridate    1.3.3     2013-12-31 CRAN (R 3.1.2)                    
 magrittr   * 1.5       2014-11-22 CRAN (R 3.1.2)                    
 memoise    * 0.2.1     2014-04-22 CRAN (R 3.1.2)                    
 mime       * 0.2       2014-09-26 CRAN (R 3.1.2)                    
 pbapply      1.1-1     2014-05-16 CRAN (R 3.1.2)                    
 plyr       * 1.8.1     2014-02-26 CRAN (R 3.1.2)                    
 R6         * 2.0.1     2014-10-29 CRAN (R 3.1.2)                    
 Rcpp       * 0.11.3    2014-09-29 CRAN (R 3.1.2)                    
 RCurl      * 1.95-4.5  2014-12-28 CRAN (R 3.1.2)                    
 RJSONIO    * 1.3-0     2014-07-28 CRAN (R 3.1.2)                    
 RSQLite      1.0.0     2014-10-25 CRAN (R 3.1.2)                    
 rstudio    * 0.98.1091 2015-01-19 local                             
 rstudioapi * 0.2       2014-12-31 CRAN (R 3.1.2)                    
 shiny        0.10.2.2  2014-12-08 CRAN (R 3.1.2)                    
 stringi      0.4-1     2014-12-14 CRAN (R 3.1.2)                    
 stringr    * 0.6.2     2012-12-06 CRAN (R 3.1.2)                    
 xtable     * 1.7-4     2014-09-12 CRAN (R 3.1.2) 

也许这是R版本的问题?

4 个答案:

答案 0 :(得分:10)

输出中有两个明确说明的问题:

  1. 第一个是警告,您可能要删除a.out/
  2. 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
    
    1. 第二个是错误和你的交易破坏者 - 你安装了libxml2-dev(或任何CentOS调用它):
    2. checking for xml2-config... no
      Cannot find xml2-config
      

      如果没有libxml2-dev提供的XML开发工具,您就无法从源代码构建软件包。

答案 1 :(得分:1)

如果您使用的是Fedora,CentOs或RedHat,则需要安装libxml2-devel。

dnf install libxml2-devel 

答案 2 :(得分:1)

在Centos 7的命令行上安装sudo yum install libxml2-devel

然后install.packages(“XML”)

答案 3 :(得分:0)

如果在ubuntu上:

sudo apt-get install libxml2-dev