垂死病中惊坐起1,上来吐槽我自己。
自从转学到 R 以后,整个特征工程中只剩一步还是用 Python 在跑。昨天忽然发现原来有个 R 包已经实现了那一步,便想着在服务器的 R 环境中安装这个包,这样肯定比在本地跑数快很多。不过安装那个包的时候得先装个依赖包 openxlsx,然而 Linux 上直接装报错了,于是我又上 Rstudio Server 尝试从本地装,仍然报错,错误如下。
> install.packages("~/R/RData/openxlsx_4.2.5.tar.gz", repos = NULL, type = "source")
Installing package into ‘/home/hadoop/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package ‘openxlsx’ ...
** package ‘openxlsx’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -I"/home/pakage/R-4.0.3/lib64/R/include" -DNDEBUG -I'/home/pakage/R-4.0.3/lib64/R/library/Rcpp/include' -I/usr/local/include -fpic -fsanitize=undefined,address -fno-omit-frame-pointer -c RcppExports.cpp -o RcppExports.o
g++: error: unrecognized command line option ‘-fsanitize=undefined,address’
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘openxlsx’
* removing ‘/home/hadoop/R/x86_64-pc-linux-gnu-library/4.0/openxlsx’
Warning in install.packages :
installation of package ‘/home/hadoop/R/RData/openxlsx_4.2.5.tar.gz’ had non-zero exit status
这个错误看得我很迷茫,把g++: error: unrecognized command line option ‘-fsanitize=undefined,address’
这段粘出来上网一搜,说是要更新 gcc。俺对 Linux 很不熟,寻思着装 R 包跟那个 gcc 应该扯不上关系,于是尝试想别的办法。
-
一是猜会不会是 openxlsx 版本太新了,当下最新是4.2.5,于是换4.2.3、4.2.2试了下还是报一样的错。
-
二是猜
install.packages
这个函数里会不会有什么参数设置了能直接忽略那个错误,然而??
出来的内容看不懂。
所以还是去找办法更新 gcc 了,好在找到一个简洁清晰的离线升级gcc的博客,照着鼓捣升级 gcc 以后居然还是报错了,而且报的错误上网搜都搜不到相关的,错误如下。
> install.packages("~/R/RData/openxlsx_4.2.5.tar.gz", repos = NULL, type = "source")
Installing package into ‘/home/hadoop/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package ‘openxlsx’ ...
** package ‘openxlsx’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -I"/home/pakage/R-4.0.3/lib64/R/include" -DNDEBUG -I'/home/pakage/R-4.0.3/lib64/R/library/Rcpp/include' -I/usr/local/include -fpic -fsanitize=undefined,address -fno-omit-frame-pointer -c RcppExports.cpp -o RcppExports.o
g++ -I"/home/pakage/R-4.0.3/lib64/R/include" -DNDEBUG -I'/home/pakage/R-4.0.3/lib64/R/library/Rcpp/include' -I/usr/local/include -fpic -fsanitize=undefined,address -fno-omit-frame-pointer -c helper_functions.cpp -o helper_functions.o
g++ -I"/home/pakage/R-4.0.3/lib64/R/include" -DNDEBUG -I'/home/pakage/R-4.0.3/lib64/R/library/Rcpp/include' -I/usr/local/include -fpic -fsanitize=undefined,address -fno-omit-frame-pointer -c load_workbook.cpp -o load_workbook.o
load_workbook.cpp: In function ‘Rcpp::CharacterVector getChildlessNode(std::string, std::string)’:
load_workbook.cpp:925:10: error: ‘itr’ does not name a type
auto itr = 0;
^
load_workbook.cpp:934:11: error: ‘itr’ was not declared in this scope
if (itr == 0) begPos = begPos + begTag.length();
^
load_workbook.cpp:945:9: error: ‘itr’ was not declared in this scope
++itr;
^
make: *** [load_workbook.o] Error 1
ERROR: compilation failed for package ‘openxlsx’
* removing ‘/home/hadoop/R/x86_64-pc-linux-gnu-library/4.0/openxlsx’
Warning in install.packages :
installation of package ‘/home/hadoop/R/RData/openxlsx_4.2.5.tar.gz’ had non-zero exit status
接着又试着装 openxlsx 4.2.2也还是报错,这时候半个下午过去了,心想着填坑进度稍有些滞后,接下来的一个步骤在本地写和在服务器写是一样的,于是打算暂且搁置,先干活,等以后有时间再来鼓捣。
不知是不是平时抱怨前同事的替补选手一直没招到的事被领导听进去了,可能也因为我每次在服务器上鼓捣都磕磕绊绊的,也会时不时打扰到领导,今早领导居然主动提出帮我去装昨天没装好的包。后来领导很快装好了。我问怎么装的。答:此包版本太新,这个坑还没什么人趟过,只是找了旧版本的包来装就装上了。我瞅了眼,确实装的是 openxlsx 4.1.5。现在想想,其实我默认了服务器上的 R 能够安装最新版本的 openxlsx,因为看这里写着Depends: R (≥ 3.3.0)
,以及Published: 2021-12-14
,而服务器上的 R 版本是R version 4.0.3 (2020-10-10)
,于是下载包的时候最多只试到了4.2.2。当我写到这里的时候,记忆告诉我当时还把2020和2021搞混了……
勘误:换了个gcc没升级的环境,直接安装 openxlsx 4.1.5也还是报一样的错,所以之前没装成功的原因确实就是gcc版本太旧。
-
这诗句原是“垂死病中惊坐起,暗风吹雨入寒窗”,但不知为何清楚记得上半句,却对下半句毫无印象,大概是网络上对上半句造梗太多了吧。 ↩︎