简体   繁体   中英

Installing Keras for R - reticulate package fails with “Rcpp.h: No such file or directory”

I'm pretty new to R and I'm banging my head against the wall here trying to install Keras for R. Running with R 3.4.1 and 1.0.153 on Windows 10. I've installed Rcpp and devtools, but when running

devtools::install_github("rstudio/keras")

it fails when attempting to install the reticulate package

* 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'

One thing that strikes me as odd is the include directives to g++, especially

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

I have no idea where it got this path, but is't certainly nothing that exist on my local machine.

I've tried reinstalling both R and RStudio, but to no avail. Any ideas on how to move forward?

I finally found the issue; After reading this post I realized that the UNC path is the problem: How do I change the default library path for R packages In Rstudio, when running

.libPaths()

I got back two results

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

There seems to be a number of ways to fix this, but what I did was edit the Rprofile.site (found in RHOME/etc) to contain

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM