R devtools 失败,因为 "Package libxml-2.0 was not found in the pkg-config search path"
R devtools fails as "Package libxml-2.0 was not found in the pkg-config search path"
我正在尝试在 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
但是这似乎不起作用。
安装R包"XML"的更窄问题,直接做
sudo apt-get install r-cran-xml
否则,从 "devtools" 的依赖项列表开始(例如来自 here)并一一安装这些依赖项。
好的所以最后我不得不手动安装 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")
成功完成。
在 R 提示符下,如果已安装 libxml2-dev
,则此命令有效:
Sys.setenv(PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig")
根据您的 Linux 风格从下面选择并安装合适的库:-
- deb: libxml2-dev (Debian, Ubuntu, etc)
- rpm: libxml2-devel (Fedora, CentOS, RHEL)
- csw: libxml2_dev (Solaris)
使用适当的命令安装,如 apt-get、yum 等
今天,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 是对的)。注释掉测试,让我可以手动安装软件包而不会出现任何其他问题。
我在 Fedora 31 上遇到了这个问题(截至 2020 年 4 月;xml2
安装时出错)。安装 libxml2-devel
似乎为我解决了这个问题。
$ dnf install libxml2-devel
我正在尝试在 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
但是这似乎不起作用。
安装R包"XML"的更窄问题,直接做
sudo apt-get install r-cran-xml
否则,从 "devtools" 的依赖项列表开始(例如来自 here)并一一安装这些依赖项。
好的所以最后我不得不手动安装 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")
成功完成。
在 R 提示符下,如果已安装 libxml2-dev
,则此命令有效:
Sys.setenv(PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig")
根据您的 Linux 风格从下面选择并安装合适的库:-
- deb: libxml2-dev (Debian, Ubuntu, etc)
- rpm: libxml2-devel (Fedora, CentOS, RHEL)
- csw: libxml2_dev (Solaris)
使用适当的命令安装,如 apt-get、yum 等
今天,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 是对的)。注释掉测试,让我可以手动安装软件包而不会出现任何其他问题。
我在 Fedora 31 上遇到了这个问题(截至 2020 年 4 月;xml2
安装时出错)。安装 libxml2-devel
似乎为我解决了这个问题。
$ dnf install libxml2-devel