无法在r中安装XML包

时间:2016-11-18 17:13:53

标签: r xml libxml2

我正在尝试在r中安装“XML”包,但是会发生错误 请告诉我出了什么问题。

操作系统:OS X 10.11.6
R版本:3.3.2
执行“install.packages(”XML“)时的错误消息如下。

* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
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
checking for sed... /usr/bin/sed
checking for pkg-config... /usr/local/bin/pkg-config
checking for xml2-config... /usr/bin/xml2-config
USE_XML2 = yes
SED_EXTENDED_ARG: -E
Minor 9, Patch 2 for 2.9.2
Located parser file -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2/parser.h
Checking for 1.8:  -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2
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’

我设置LIBXML_INCDIR = / usr / local / Cellar / libxml2 / 2.9.4,然后重试。
然后发生另一个错误。

* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
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
checking for sed... /usr/bin/sed
checking for pkg-config... /usr/local/bin/pkg-config
Checking directory of LIBXML_INCDIR
You specified LIBXML_INCDIR, but we couldn't find parser.h
Please specify it correctly and re-run the INSTALL'ation.
ERROR: configuration failed for package ‘XML’

还尝试使用LIBXML_INCDIR = / usr / local / Cellar / libxml2 / 2.9.4 / include
结果与上述相同。

此致

3 个答案:

答案 0 :(得分:5)

这在Mac OS X 10.11中适用于我:

在终端:

type xml2-config
xml2-config is /opt/local/bin/xml2-config

在R:

Sys.setenv(XML_CONFIG="/opt/local/bin/xml2-config")

答案 1 :(得分:0)

您可以编辑文件beer以包含:

,而不是强制链接libxml2版本与自制程序。

$HOME/.R/Makevars

编辑SDK版本(例如上例中的MacOSX10.13)以匹配您安装的版本。有关(最小)解释,请参阅https://forums.developer.apple.com/thread/87829

答案 2 :(得分:0)

对于Homebrew的libxml2安装,我使用了:

export XML_CONFIG=/usr/local/Cellar//libxml2/2.9.10_1/bin/xml2-config 

它奏效了。