can not install XML package

Hi
I can not install XML package on R-Studio Pro
I am using R version 3.6.1 :

> install.packages("XML")
Installing package into ‘/home/juri.kuusik/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying ...
Content type 'application/x-gzip' length 1600829 bytes (1.5 MB)
==================================================
downloaded 1.5 MB

* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
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... /usr/bin/pkg-config
checking for xml2-config... /opt/python/3.6.5/bin/xml2-config
USE_XML2 = yes
SED_EXTENDED_ARG: -E
Minor 9, Patch 8 for 2.9.8
Located parser file -I/opt/python/3.6.5/include/libxml2 -I/opt/python/3.6.5/include/parser.h
Checking for 1.8:  -I/opt/python/3.6.5/include/libxml2 -I/opt/python/3.6.5/include
Using libxml2.*
checking for gzopen in -lz... yes
checking for xmlParseFile in -lxml2... no
checking for xmlParseFile in -lxml... no
configure: error: "libxml not found"
ERROR: configuration failed for package ‘XML’
* removing ‘/home/juri.kuusik/R/x86_64-pc-linux-gnu-library/3.6/XML’
Warning in install.packages :
  installation of package ‘XML’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpCCCTwU/downloaded_packages’
1 Like

You are missing a system requirement it seems.

See on the CRAN page

SystemRequirements: libxml2 (>= 2.6.3)

You need to install it before installing the R package.

Also for xml files you have the xml2 :package:, but you'll also need to install the linux requirement beforhand

1 Like

What @cderv describes comes up pretty often. Use your package manager to install the external dependency that's missing:

sudo apt-get install libxml2

on Ubuntu, for example

1 Like

Hi.
Thanks for answer.
However I have libxml2 already available:

[juri.kuusik@rstudio-pro ~]$ sudo yum install libxml2
...
...
Package libxml2-2.9.1-6.el7_2.3.x86_64 already installed and latest version
Nothing to do

I tried to install XML package again and got the same error in R
I have Python 3.6.5 also in my server - maybe that the problem ?
R is trying to use configurations from wrong place ?

It seems you are right. I did not see that at first. It seems the R installation is using the python libxml2 installation. It may not be the same. You should check that.

You may be able to use environment variable to precise the path to your libxml library to change the one change by pkg-config

There are also other environment variables that could be used to configure the compilation.
like XML/configure at 1200e8d2e2cd4910537b700245c9d58350c3e351 · omegahat/XML · GitHub

I did not find a lot of documentation for changing the default.

I guess you can also change you pkgconfig configuration so that the python one is not found by default.

For xml2, the configuration can use --configure-vars installation option, to precise INCLUDE_DIR and LIB_DIR (see configure too)

Hope you'll find how to do this. I think you are on the right track.

Thanks.
At the moment I removed Python folder and then re-installed XML package - it succeeded

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.