我使用Windows 10,在" C:\ Program Files \ MySQL \ MySQL Server 5.7"下安装了MySQL,在" D:\ R \ R-3.3.2&#34下安装了R ;,在" D:\ Rtools"下安装了Rtools,在" D:\ RStudio"下安装了RStudio。然后我按照以下步骤安装RMySQL包:
1:在我的环境变量中添加了MYSQL_HOME = C:\ Program Files \ MySQL \ MySQL Server 5.7 \。
2:在" D:\ R \ R-3.3.2 \ etc"下创建了Renviron.site文件。内容:MYSQL_HOME = C:/ Program Files / MySQL / MySQL Server 5.7 /
3:验证我的环境变量下的Path值 - >系统变量确实包含:D:\ Rtools \ bin; D:\ Rtools \ mingw_32 \ bin; ...
4:在RStudio上运行install.packages(" RMySQL",type =" source")。
但我收到以下错误消息:
> install.packages("RMySQL", type = "source")
trying URL 'https://cran.rstudio.com/src/contrib/RMySQL_0.10.9.tar.gz'
Content type 'application/x-gzip' length 54012 bytes (52 KB)
downloaded 52 KB
* installing *source* package 'RMySQL' ...
** 成功将'RMySQL'程序包解包并MD5和检查
** libs
*** arch - i386
rm -f RMySQL-init.o connection.o db-apply.o driver.o exception.o fields.o result.o utils.o RMySQL.dll
"D:/R/R-3.3.2/bin/i386/Rscript.exe" "../tools/winlibs.R"
c:/Rtools/mingw_32/bin/gcc -I"D:/R/R-3.3.2/include" -DNDEBUG -I../windows/libmariadbclient-2.1.0/include -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c RMySQL-init.c -o RMySQL-init.o
c:/Rtools/mingw_32/bin/gcc: not found
make: *** [RMySQL-init.o] Error 127
Warning: 运行命令'make -f "Makevars.win" -f "D:/R/R-3.3.2/etc/i386/Makeconf" -f "D:/R/R-3.3.2/share/make/winshlib.mk" SHLIB="RMySQL.dll" OBJECTS="RMySQL-init.o connection.o db-apply.o driver.o exception.o fields.o result.o utils.o"' had status 2
ERROR: compilation failed for package 'RMySQL'
* removing 'D:/R/R-3.3.2/library/RMySQL'
Warning in install.packages :
running command '"D:/R/R-3.3.2/bin/x64/R" CMD INSTALL -l "D:\R\R-3.3.2\library" C:\Users\Xuan\AppData\Local\Temp\RtmpkjaBSm/downloaded_packages/RMySQL_0.10.9.tar.gz' had status 1
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\Xuan\AppData\Local\Temp\RtmpkjaBSm\downloaded_packages’
我看到错误消息说" c:/ Rtools / mingw_32 / bin / gcc:not found",这可能是因为我在D盘下安装了RTools。我可以成功安装其他R包(这意味着Rtools可以在R中使用),但我不知道为什么这个安装得到了错误的路径。谁能帮忙解决这个问题?非常感谢!
答案 0 :(得分:0)
通过将整个Rtools文件夹复制到C盘来解决此问题。 R可以正确加载RMySQL包,尽管这会占用我系统驱动器的相当大的空间。