Homies~,该文章非万能解决方案,一况一论!
[toc]
说在前面
stringi
这个包麻烦这个是大家都知道的,win、macos麻烦,linux的更麻烦...
stringi
是 R 语言中的一个非常流行和强大的字符串处理包。它提供了一系列的功能,用于处理和操作字符串数据,特别是对于国际化和本地化的文本处理。stringi
基于 ICU(International Components for Unicode)库,这是一个广泛使用的、跨平台的、针对 Unicode 标准的 C 库。stringi
是许多 R 包的依赖包。由于它提供了一系列强大且灵活的字符串处理功能,stringi
成为了许多开发者的首选包来处理字符串相关的任务。这些功能包括但不限于字符串的搜索、替换、排序、分割和国际化处理。
上述是引用GPT的话来凑字数,大家记住两点即可:
- stringi是基于C/C++开发的
二进制
分发包,跟源码,平台依赖性强,所以说linux安装起来挺麻烦,如果报错起来不同发行版不同C库不同版本号都可能会有不同的情况,M3~ - stringi、stringr这些,是几乎,God的,所有生信/统计分析所用到的R包的依赖包,绕不过去的,只能解决报错,乖乖安装。
这个包笔者曾经刚学R的时候也苦受折磨,自己本地的win本安装无问题,但是实验室服务安装,卒;后面入坑了黑苹果,卒;换了macbook,卒~
怎么办
怎么办,八仙过海各显神通,随机应变灵活解决。
1st:GCC版本问题
这是笔者第一次记录过的解决方案,当时是用的服务器,用jupyter死活装不成功捣鼓了几天:
在C站有blog这里就不重复了,可以参考一下,那一次是版本问题好像是,https://blog.csdn.net/weixin_48093827/article/details/130066097
2st:不确定是环境还是网络问题
报错内容:
> install.packages("stringi")
Installing package into ‘/home/xu_zw/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://mirrors.e-ducation.cn/CRAN/src/contrib/stringi_1.7.12.tar.gz'
Content type 'application/x-gzip' length 7602365 bytes (7.3 MB)
==================================================
downloaded 7.3 MB
* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
** using staged installation
checking for R_HOME... /opt/R/4.2.1/lib/R
checking for R... /opt/R/4.2.1/lib/R/bin/R
checking for endianness... little
checking for R >= 3.1.0 for C++11 use... yes
checking for R < 3.4.0 for CXX1X flag use... no
checking for cat... /usr/bin/cat
checking for local ICUDT_DIR... icu69/data
checking for gcc... gcc -std=gnu11
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc -std=gnu11 accepts -g... yes
checking for gcc -std=gnu11 option to enable C11 features... none needed
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for elf.h... yes
checking whether the compiler supports GNU C++... yes
checking whether g++ -std=gnu++11 accepts -g... yes
checking for g++ -std=gnu++11 option to enable C++11 features... none needed
checking whether the C++ compiler supports the long long type... yes
checking whether the compiler implements namespaces... yes
checking whether the compiler supports the Standard Template Library... yes
checking whether std::map is available... yes
checking for pkg-config... /usr/bin/pkg-config
checking with pkg-config for the system ICU4C... 50.2
checking for ICU4C >= 55... no
*** ICU4C 50.2 has been detected
*** Minimal requirements, i.e., ICU4C >= 55, are not met
*** Trying with 'standard' fallback flags
checking whether an ICU4C-based project can be built... yes
checking programmatically for sufficient U_ICU_VERSION_MAJOR_NUM... no
*** This version of ICU4C cannot be used.
*** Using the ICU 69 bundle.
checking whether we may compile src/icu69/common/putil.cpp... yes
checking whether we may compile src/icu69/i18n/number_affixutils.cpp... yes
checking whether alignof(std::max_align_t) is available... yes
checking whether the ICU data library can be downloaded... downloading the ICU data library (icudt)
output path: icu69/data/icu4c-69_1-data-bin-l.zip
trying URL 'https://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip'
Error in download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb"): cannot open URL 'https://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip'
trying URL 'http://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip'
Error in download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb"): cannot open URL 'http://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip'
icudt download failed
Error: Stopping on error
In addition: Warning messages:
1: In download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb") :
URL 'https://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip': status was 'Couldn't connect to server'
2: In download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb") :
URL 'http://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip': status was 'Couldn't connect to server'
Execution halted
*** *********************************************************************
*** stringi cannot be built.
*** Failed to download the ICU data library (icudt). Stopping now.
*** For build environments that have no internet access,
*** see the INSTALL file for a workaround.
*** *********************************************************************
ERROR: configuration failed for package ‘stringi’
* removing ‘/home/xu_zw/R/x86_64-pc-linux-gnu-library/4.2/stringi’
* restoring previous ‘/home/xu_zw/R/x86_64-pc-linux-gnu-library/4.2/stringi’
The downloaded source packages are in
‘/tmp/Rtmp1tLgZj/downloaded_packages’
Warning message:
In install.packages("stringi") :
installation of package ‘stringi’ had non-zero exit status
这次的报错,不确定是环境问题还是网络问题,单看报错内容,应该是网络问题,但是我尝试ping一下github
是有回应的。谷歌了一下,有说版本问题的,以及还是库的,问题。
版本的问题也看了,非也
type shit~ Conda也是过了,装不成功的
大家留意报错内容ERROR的部分,不尽相同的!!M3~
这环节可以参考一下官网的方法:
https://stringi.gagolewski.com/install.html
本篇的成功解决方法
1.加载ICUDT安装,官方文件https://raw.githubusercontent.com/gagolews/stringi/master/INSTALL,应该要科学上网
install.packages("stringi", configure.vars="ICUDT_DIR=<icudt_dir>")
2.不行没关系,自己下载安装解压
wget https://github.com/gagolews/stringi/archive/master.zip -O stringi.zip
unzip stringi.zip
sed -i '/\/icu..\/data/d' stringi-master/.Rbuildignore
R CMD build stringi-master
3.终端或者在R中下载r包,xyz换成第二步结果的版本号,例如这里是1.8.1
# bash
R CMD INSTALL stringi_x.y.z.tar.gz
# R
install.packages("stringi_x.y.z.tar.gz", repos=NULL)
4.over~
如有其他情况或者其他解决方案,欢迎大家私信交流,my heart~