【问题标题】:R devtools fails as "Package libxml-2.0 was not found in the pkg-config search path"R devtools 失败,因为“在 pkg-config 搜索路径中找不到包 libxml-2.0”
【发布时间】:2015-10-26 03:56:20
【问题描述】:

我正在尝试在 R 版本 3.2.1 中安装 devtools,但是当我这样做时会抛出以下错误:

Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing libxml-2.0.pc
to the PKG_CONFIG_PATH environment variable

当我在终端中运行 dpkg -L libxml2-dev 时,我发现:

/usr
/usr/bin
/usr/bin/xml2-config
/usr/share
/usr/share/aclocal
/usr/share/aclocal/libxml2.m4
/usr/share/doc
/usr/share/doc/libxml2-dev
/usr/share/doc/libxml2-dev/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/xml2-config.1.gz
/usr/share/man/man3
/usr/share/man/man3/libxml.3.gz
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libxml2.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libxml-2.0.pc
/usr/lib/x86_64-linux-gnu/xml2Conf.sh
/usr/include
/usr/include/libxml2
/usr/include/libxml2/libxml
/usr/include/libxml2/libxml/globals.h
/usr/include/libxml2/libxml/schematron.h
/usr/include/libxml2/libxml/xlink.h
/usr/include/libxml2/libxml/HTMLparser.h
/usr/include/libxml2/libxml/pattern.h
/usr/include/libxml2/libxml/xmlexports.h
/usr/include/libxml2/libxml/xmlschemas.h
/usr/include/libxml2/libxml/list.h
/usr/include/libxml2/libxml/entities.h
/usr/include/libxml2/libxml/xmlstring.h
/usr/include/libxml2/libxml/encoding.h
/usr/include/libxml2/libxml/hash.h
/usr/include/libxml2/libxml/xmlmemory.h
/usr/include/libxml2/libxml/relaxng.h
/usr/include/libxml2/libxml/xmlsave.h
/usr/include/libxml2/libxml/SAX2.h
/usr/include/libxml2/libxml/xmlIO.h
/usr/include/libxml2/libxml/xmlschemastypes.h
/usr/include/libxml2/libxml/xpathInternals.h
/usr/include/libxml2/libxml/schemasInternals.h
/usr/include/libxml2/libxml/xmlmodule.h
/usr/include/libxml2/libxml/valid.h
/usr/include/libxml2/libxml/c14n.h
/usr/include/libxml2/libxml/xmlwriter.h
/usr/include/libxml2/libxml/tree.h
/usr/include/libxml2/libxml/xmlunicode.h
/usr/include/libxml2/libxml/nanohttp.h
/usr/include/libxml2/libxml/catalog.h
/usr/include/libxml2/libxml/xmlerror.h
/usr/include/libxml2/libxml/nanoftp.h
/usr/include/libxml2/libxml/xmlautomata.h
/usr/include/libxml2/libxml/xinclude.h
/usr/include/libxml2/libxml/HTMLtree.h
/usr/include/libxml2/libxml/chvalid.h
/usr/include/libxml2/libxml/parserInternals.h
/usr/include/libxml2/libxml/xpointer.h
/usr/include/libxml2/libxml/xmlversion.h
/usr/include/libxml2/libxml/dict.h
/usr/include/libxml2/libxml/xmlregexp.h
/usr/include/libxml2/libxml/DOCBparser.h
/usr/include/libxml2/libxml/parser.h
/usr/include/libxml2/libxml/xmlreader.h
/usr/include/libxml2/libxml/SAX.h
/usr/include/libxml2/libxml/threads.h
/usr/include/libxml2/libxml/debugXML.h
/usr/include/libxml2/libxml/xpath.h
/usr/include/libxml2/libxml/uri.h
/usr/share/doc/libxml2-dev/README
/usr/share/doc/libxml2-dev/NEWS.gz
/usr/share/doc/libxml2-dev/AUTHORS
/usr/share/doc/libxml2-dev/TODO.gz
/usr/share/doc/libxml2-dev/changelog.Debian.gz
/usr/lib/x86_64-linux-gnu/libxml2.so

尝试将此添加到PKG_CONFIG_PATH 我尝试过:env PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig 但这似乎不起作用。

【问题讨论】:

  • 你在运行dpkg -L libxml2-dev时只得到这两行?如果是,libxml2 可能没有安装。
  • @Pascal,不,我刚刚添加了两个似乎相关的内容。为了清楚起见,我现在添加了通话的完整输出。

标签: xml r ubuntu devtools pkg-config


【解决方案1】:

好的,所以最后我不得不手动安装 libxml2,即使我的系统说它已经安装了最新版本:sudo apt-get install libxml2 libxml2-dev

我根据here找到的信息手动安装:

wget ftp://xmlsoft.org/libxml2/libxml2-2.9.2.tar.gz

然后uppack到一个目录,例如:

tar -xvf libxml2-2.9.2.tar.gz
cd libxml2-2.9.2

配置安装:

./configure --prefix=/usr --disable-static --with-history && make

sudo make install

在此之后,R 命令 install.packages("devtools") 成功完成。

【讨论】:

  • 很高兴知道。这里有一个 Debian/Ubuntu 错误,和/或 xml2 包的一个错误。无论哪种情况,您都不应该将/usr/local 更改为/usr,因为您现在继续将本地安装与包安装混合在一起。这通常是个坏主意...
  • 这在 Ubuntu 18.04 上对我有用,在 wget 步骤之后没有做任何事情
【解决方案2】:

根据您的 Linux 风格从下面选择并安装合适的库:-

  • deb:libxml2-dev(Debian、Ubuntu 等)
  • rpm:libxml2-devel(Fedora、CentOS、RHEL)
  • csw: libxml2_dev (Solaris)

使用适当的命令安装,例如 apt-get、yum 等。

【讨论】:

  • 请注意,如果您采用apt-get, yum, etc. 方式,由于未正确安装libxml2-dev,您可能仍会收到错误消息。在 Ubuntu 18.04 上对我有用的是上面 @mattbawn 建议的命令 wget ftp://xmlsoft.org/libxml2/libxml2-2.9.2.tar.gz
【解决方案3】:

在 R 提示符下,如果已安装 libxml2-dev,则此命令有效:

Sys.setenv(PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig")

【讨论】:

  • 我的具体问题似乎是我的系统无法识别 libxml2-dev 的配置但提示 +1 的问题!
  • 我遇到了同样的问题。在尝试手动安装 libxml2-dev 之前,我先尝试了这个,它有帮助
【解决方案4】:

对于安装R包“XML”的狭隘问题,只需这样做

 sudo apt-get install r-cran-xml

否则,从“devtools”的依赖项列表开始(例如来自here)并一一安装这些依赖项。

【讨论】:

  • 感谢您的回答,但我想我错过了一些东西。如果我这样做并再次尝试安装 devtools,安装仍然会失败并出现相同的错误。 * installing *source* package ‘xml2’ ... ** package ‘xml2’ successfully unpacked and MD5 sums checked Package libxml-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing libxml-2.0.pc' to the PKG_CONFIG_PATH environment variable。你能帮我澄清一下吗?
  • 抱歉,它是包xml2,而不是包XML,二进制文件对您没有帮助。我对安装依赖项的建议一一并检查它们各自的错误日志仍然有效。所有这些软件包在我所有的 Ubuntu 机器上都安装得很好......
【解决方案5】:

我在 Fedora 31 上遇到了这个问题(截至 2020 年 4 月;xml2 安装出错)。安装libxml2-devel 似乎可以解决我的问题。

$ dnf install libxml2-devel

【讨论】:

  • 谢谢,我在 MX Linux 上安装 tidyverse 时遇到问题,这是我丢失的软件包之一,但错误消息没有提到 libxml2-devel。
【解决方案6】:

4 年零 2 个月后的今天,我遇到了完全相同的问题(即使在安装不同包 xml2 的情况下)。

仔细查看包的.configure脚本,发现下面一行配置测试失败:

echo "#include $PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/null 2>&1 || R_CONFIG_ERROR=1;

尽管所有使用的参数都具有正确且非空值,但仍然如此。

我不确定为什么这个测试会失败,但这似乎是一个错误(所以 Dirk Eddelbuettel 是对的)。注释掉测试,让我可以手动安装包而没有任何进一步的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-07
    • 2013-02-25
    • 1970-01-01
    • 1970-01-01
    • 2014-10-27
    • 2022-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多