問題
Linux環(huán)境下山憨,使用conda成功安裝了R4查乒。但提示‘utils’和‘stats’包未找到,如下:
R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-conda-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
During startup - Warning messages:
1: package ‘utils’ in options("defaultPackages") was not found
2: package ‘stats’ in options("defaultPackages") was not found
此時(shí)安裝R包或運(yùn)行其他命令都直接報(bào)錯(cuò)郁竟,如:
> install.packages("ggplot2")
Error in install.packages("ggplot2") :
could not find function "install.packages"
解決一
沒去分析原因玛迄,在網(wǎng)上查了下。找到安裝R環(huán)境下的庫文件ldpaths棚亩,最后一行加上export EDITOR=vim
蓖议,好像可以。如下:
echo "export EDITOR=vim" >> /opt/conda/envs/r4py3/lib/R/etc/ldpaths
正常蔑舞。
R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-conda-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
但是,當(dāng)我第二次用docker打包時(shí)嘹屯,卻又出現(xiàn)了這個(gè)玩意。說明以上方法不是根本的解決之道。
解決二
網(wǎng)上又查了一圈殿雪,說是conda新建的環(huán)境中沒有which嘿悬,安裝which即可。
(r4py3) [root@a3ef4a44aa1f etc]# which
bash: which: command not found
(r4py3) [root@a3ef4a44aa1f etc]# yum install -y which
https://github.com/ContinuumIO/anaconda-issues/issues/11133
https://www.cnblogs.com/flowerbirds/p/14191783.html
確實(shí)婆翔,安裝后一切又正常了拯杠。
(r4py3) [root@a3ef4a44aa1f etc]# R
R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-conda-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
然而,網(wǎng)上仍有一些回答說他們安裝which
也沒用啃奴。
R depends on which, which might not be present in the conda R environment. Maybe it could be as simple as to add the which-derivation to conda?
Placing ‘which’ into the conda binary folder did however not fix the issue (the R console still complains about not being able to load stats and utils packages)
https://discourse.nixos.org/t/r-installation-within-conda-cannot-find-default-libraries/8437
一些人建議設(shè)置set R_HOME path
潭陪,也有建議重新安裝其他版本的R。
我用which成功解決最蕾,后續(xù)沒什么問題了依溯,就沒嘗試了。還有不成功的小伙伴可以多試試多查查瘟则,大不了重新安裝黎炉。