【问题标题】:Cannot install XML package in r无法在 r 中安装 XML 包
【发布时间】:2016-11-18 17:13:53
【问题描述】:

我正在尝试在 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
结果和上面一样。

问候

【问题讨论】:

  • 看来问题不在于LIBXML_INCDIR,而是找不到共享库文件。在第一次尝试中找到parser.h,当您未指定时:Located parser file -I/Applications/Xcode.app/[...]
  • 感谢您的评论。我猜LIBXML_INCDIR在第一次尝试时不是问题,但是我对解决方案没有任何想法,所以我尝试了一下,只是因为LIBXML_INCDIR据说与某些网页上的libxml有关。请原谅我缺乏解释。
  • 尝试从终端运行brew link libxml2,然后重新安装R包。
  • 非常感谢。 “brew link libxml2 --force”有效。
  • @Ken 我遇到了同样的问题,但brew link libxml2 --force 不适合我。你在哪里指定LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.4/include?感谢您在此处提供的任何帮助。

标签: r xml libxml2


【解决方案1】:

这在 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")

【讨论】:

  • 我在 Mac OS X 10.12 上遇到了问题,我使用了 Homebrew。我的 xml2-config 位于 /usr/local/Cellar/libxml2/2.9.7/bin/xml2-config
【解决方案2】:

您可以编辑文件$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

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

【讨论】:

    【解决方案3】:

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

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

    它成功了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-14
      • 2020-07-02
      • 2015-12-22
      • 2018-09-24
      • 2014-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多