在R的交互环境下利用 install.packages(“RMySQL”)在线安装RMySQL程序包出现如下错误:
> install.packages("RMySQL")
将程序包安装入‘/usr/local/lib/R/site-library’
(因为‘lib’没有被指定)
Warning in install.packages("RMySQL") :
'lib="/usr/local/lib/R/site-library"'不可写
Would you like to use a personal library instead? (y/n) y
Would you like to create a personal library
~/R/x86_64-pc-linux-gnu-library/3.4
to install packages into? (y/n) y
Warning: 无法在貯藏處https://cloud.r-project.org/src/contrib中读写索引:
无法打开URL'https://cloud.r-project.org/src/contrib/PACKAGES'
Warning message:
package ‘RMySQL’ is not available (for R version 3.4.4)
再次尝试,仍然报错,但是提示需要依赖安装DBI程序包。
> install.packages("RMySQL")
将程序包安装入‘/home/hadoop/R/x86_64-pc-linux-gnu-library/3.4’
(因为‘lib’没有被指定)
还安装相依关系‘DBI’
试开URL’https://cloud.r-project.org/src/contrib/DBI_0.8.tar.gz'
Error in download.file(url, destfile, method, mode = "wb", ...) :
无法打开URL'https://cloud.r-project.org/src/contrib/DBI_0.8.tar.gz'
此外: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://cloud.r-project.org/src/contrib/DBI_0.8.tar.gz': status was 'SSL connect error'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
下载程序包‘DBI’时出了问题
试开URL’https://cloud.r-project.org/src/contrib/RMySQL_0.10.14.tar.gz'
Error in download.file(url, destfile, method, mode = "wb", ...) :
无法打开URL'https://cloud.r-project.org/src/contrib/RMySQL_0.10.14.tar.gz'
此外: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://cloud.r-project.org/src/contrib/RMySQL_0.10.14.tar.gz': status was 'SSL connect error'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
下载程序包‘RMySQL’时出了问题
可能的问题原因:
1.软件源和镜像地址
2.网络原因
3.未安装mysql client library相关库
我最后利用离线安装RMySQL程序包解决了安装失败的问题。
解决方案:
命令前有>
表示在R交互环境执行,没有>
表示在终端命令模式执行。
1.安装DBI程序包
> install.packages('DBI')
这里需要多试几次,我也是试了好几次才安装好,可能和网络有关系。如果仍无法安装,试试跳过此步骤能否继续进行下去。
2.下载RMySQL程序包
点击这里下载RMySQL程序包,考虑利用离线安装程序包的方式安装RMySQL。下述命令是离线安装程序包的方式,注意CMD和INSTALL都是大写。
R CMD INSTALL RMySQL_0.10.14.tar.gz
发现仍然报错,提示Configuration failed because no mysql client library was found。根据错误信息,我们开始第3步。
3.安装libmysqlclient-dev
sudo apt-get install libmysqlclient-dev
4.再次离线安装RMySQL安装包,安装成功
R CMD INSTALL RMySQL_0.10.14.tar.gz
> .packages(all.available=TRUE)