r-安装ggigraph时找不到错误libxml-2.0



试图在我的Mac OS X上安装R包ggigraph时,遇到了依赖关系xml2的问题。

对于这个和其他包的用户来说,这似乎是一个相当常见的问题,所以在阅读了这里和其他地方的线程后,我确认了以下内容:

  • RStudio,R及其所有软件包都是最新的
  • libxml2安装在developer版本中,使用自制程序
  • 我已经将libxml-2.0.pc从自制程序文件夹复制到/usr/local/lib/pkgconfig/
  • 我已将/usr/local/lib/pkgconfig/添加到PATH和PKG_CONFIG_PATH

在安装过程中,我仍然收到以下错误消息。感谢您的帮助!

> install.packages("ggiraph")
Installing package into ‘/usr/local/lib/R/3.5/site-library’
(as ‘lib’ is unspecified)
also installing the dependency ‘xml2’
trying URL 'https://cran.rstudio.com/src/contrib/xml2_1.2.0.tar.gz'
Content type 'application/x-gzip' length 251614 bytes (245 KB)
==================================================
downloaded 245 KB
trying URL 'https://cran.rstudio.com/src/contrib/ggiraph_0.6.0.tar.gz'
Content type 'application/x-gzip' length 208710 bytes (203 KB)
==================================================
downloaded 203 KB
* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/libxml2
Using PKG_LIBS=-L/usr/lib -lxml2 -lz -lpthread -licucore -lm
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
* deb: libxml2-dev (Debian, Ubuntu, etc)
* rpm: libxml2-devel (Fedora, CentOS, RHEL)
* csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘xml2’
* removing ‘/usr/local/lib/R/3.5/site-library/xml2’
Warning in install.packages :
installation of package ‘xml2’ had non-zero exit status
ERROR: dependency ‘xml2’ is not available for package ‘ggiraph’
* removing ‘/usr/local/lib/R/3.5/site-library/ggiraph’
Warning in install.packages :
installation of package ‘ggiraph’ had non-zero exit status

这是我在使用Homebrew和libxml2的macOS上遇到的一个反复出现的问题。libxml2的includes位于编译器找不到的子目录/path/to/includes/libxml2/libxml/中。

我成功地在R中安装了xml2,做了两件事:

  1. 创建指向[...]/include/libxml2/libxml的符号链接[...]/include/libxml
  2. 将包含文件夹路径添加到INCLUDE_DIR

在终端中执行点1。虽然文件路径在您的安装中可能有所不同,但我的mac上的shell命令是:

Bash > ln -s /usr/local/Cellar/libxml2/2.9.9_2/include/libxml2/libxml /usr/local/Cellar/libxml2/2.9.9_2/include/libxml`

在RStudio的R终端执行第2点。我mac上的命令是:

R > Sys.setenv(INCLUDE_DIR = paste("/usr/local/Cellar/libxml2/2.9.9_2/include", Sys.getenv("INCLUDE_DIR"), sep = ":"))`

然后安装xml2并最终安装ggiraph:

R > install.packages(c("xml2", "ggiraph"))

相关内容

  • 没有找到相关文章

最新更新