简体   繁体   English

无法在 r 中安装 XML 包

[英]Cannot install XML package in r

I'm trying to install "XML" package in r, but an error occurs.我正在尝试在 r 中安装“XML”包,但发生错误。
Please tell me what's wrong.请告诉我怎么了。

OS: OS X 10.11.6操作系统:OS X 10.11.6
R version: 3.3.2 R 版本:3.3.2
The error message when executing "install.packages("XML") is the following.执行“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’

And I set LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.4, and tried again.我设置了 LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.4,然后再次尝试。
Then another error occurs.然后发生另一个错误。

* 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’

Also tried with LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.4/include也试过 LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.4/include
The result was same as above.结果和上面一样。

Regards问候

This worked for me in Mac OS X 10.11:这在 Mac OS X 10.11 中对我有用:

In the Terminal:在终端:

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

In R:在 R 中:

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

Rather than forcing the linking of the libxml2 version from homebrew, you can edit the file $HOME/.R/Makevars to include:您可以编辑文件$HOME/.R/Makevars以包括:

CC=clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk CXX=clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk

Edit the SDK version (ie MacOSX10.13 in above example) to match your installed version.编辑 SDK 版本(即上例中的 MacOSX10.13)以匹配您安装的版本。 See https://forums.developer.apple.com/thread/87829 for (minimal) explanation.有关(最小)解释,请参阅https://forums.developer.apple.com/thread/87829

For libxml2 install by Homebrew, I used:对于 Homebrew 安装的 libxml2,我使用了:

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

and it worked.它奏效了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM