安装ggiraph

时间:2018-12-17 09:44:44

标签: r libxml2 xml2 ggiraph

尝试在Mac OS X上安装R软件包ggiraph时遇到了依赖项xml2的问题。

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

  • RStudio,R及其所有软件包均为最新版本
  • 使用自制软件
  • libxml2安装为 developer 版本。
  • 我已将libxml-2.0.pc从Homebrew文件夹复制到/ 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

1 个答案:

答案 0 :(得分:0)

这是我在带有Homebrew和libxml2的macOS上经常遇到的问题。 libxml2的includes位于子目录/path/to/includes/libxml2/libxml/中,编译器找不到该子目录。

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

  1. 创建指向[...]/include/libxml的符号链接[...]/include/libxml2/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"))