• Linux中conda安装R出现 package ‘utils’ in options("defaultPackages") was not found?


    问题

    Linux环境下,使用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
    

    此时安装R包或运行其他命令都直接报错,如:

    > install.packages("ggplot2")
    Error in install.packages("ggplot2") :
      could not find function "install.packages"
    

    解决一

    没去分析原因,在网上查了下。找到安装R环境下的库文件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.
    

    https://www.jianshu.com/p/e0c337c50211

    但是,当我第二次用docker打包时,却又出现了这个玩意。说明以上方法不是根本的解决之道。

    解决二

    网上又查了一圈,说是conda新建的环境中没有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

    确实,安装后一切又正常了。

    (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.
    

    然而,网上仍有一些回答说他们安装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

    一些人建议设置set R_HOME path,也有建议重新安装其他版本的R。

    我用which成功解决,后续没什么问题了,就没尝试了。还有不成功的小伙伴可以多试试多查查,大不了重新安装。

  • 相关阅读:
    VS生成事件时复制文件到指定位置
    Windows服务BAT命令-安装、卸载、启动、停止
    Lambda表达式动态组装查询条件
    动软模板使用流程
    使用jquery.qrcode生成二维码
    MySQL报错:Packets larger than max_allowed_packet are not all
    Excel操作之VLOOKUP函数
    Visual Studio 编辑器打开项目后,一直提醒Vs在忙,解决方法
    使用BaiDu Java Script Web Api 在Web开发中嵌入地图使用步骤
    C#或Net连接Oracle操作提示 Oracle 客户端 version 8.1.7 或更高版本报错
  • 原文地址:https://www.cnblogs.com/jessepeng/p/16337581.html
Copyright © 2020-2023  润新知