【问题标题】:Installing Keras for R - reticulate package fails with "Rcpp.h: No such file or directory"为 R 安装 Keras - reticulate 包失败,并显示“Rcpp.h:没有这样的文件或目录”
【发布时间】:2017-08-25 07:35:51
【问题描述】:

我对 R 还是很陌生,在这里我想为 R 安装 Keras。在 Windows 10 上运行 R 3.4.1 和 1.0.153。 我已经安装了 Rcpp 和 devtools,但是在运行时

devtools::install_github("rstudio/keras")

尝试安装网状包时失败

* installing *source* package 'reticulate' ...
** libs
c:/Rtools/mingw_64/bin/g++  -I"C:/Users/danlin/R341/include" -DNDEBUG  -I"\\Mac/Home/Documents/R/win-library/3.4/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:0:
reticulate_types.h:7:18: fatal error: Rcpp.h: No such file or directory
 #include <Rcpp.h>
                  ^
compilation terminated.
make: *** [RcppExports.o] Error 1
Warning: running command 'make -f "C:/Users/danlin/R341/etc/x64/Makeconf" -f "C:/Users/danlin/R341/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="reticulate.dll" WIN=64 TCLBIN=64 OBJECTS="RcppExports.o event_loop.o libpython.o python.o"' had status 2
ERROR: compilation failed for package 'reticulate'

让我觉得奇怪的一件事是 g++ 的包含指令,尤其是

-I"d:/Compiler/gcc-4.9.3/local330/include"

我不知道它从哪里得到这条路径,但在我的本地机器上肯定不存在任何东西。

我尝试重新安装 R 和 RStudio,但无济于事。 关于如何前进的任何想法?

【问题讨论】:

  • 也许尝试安装 Rcpp 包? install.package("Rcpp")
  • 你读过帖子的第二行吗? :-)
  • 抱歉没看到。然后可能检查版本是否有问题

标签: r gcc keras rcpp


【解决方案1】:

我终于找到了问题;读完这篇文章后,我意识到 UNC 路径是问题所在:How do I change the default library path for R packages 在 Rstudio 中,运行时

.libPaths()

我得到了两个结果

[1] "\\\\Mac/Home/Documents/R/win-library"
[2] "C:/Users/danlin/R341/library"
> 

似乎有很多方法可以解决这个问题,但我所做的是编辑 Rprofile.site(在 RHOME/etc 中找到)以包含

.libPaths("C:\Users\danlin\R341\library")

【讨论】:

  • 一般来说,R 对 UNC 路径的支持是不稳定的。我会创建一个到 \\Mac 的网络驱动器快捷方式并将其用于所有内容。
  • 好收获。我认为这或多或少是 R 使用的常见问题解答,与 Rcpp、网状或 keras 关系不大。
  • 没错,安装 Keras 时出现的巧合。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-04
  • 1970-01-01
  • 2012-07-14
相关资源
最近更新 更多