【问题标题】:Why am I unable to load my packages into R even though they are installed? [duplicate]为什么我无法将我的包加载到 R 中,即使它们已安装? [复制]
【发布时间】:2020-11-12 11:54:51
【问题描述】:

我想我在加载库时不小心更改了 PATH。我知道我的包已安装,但是当我执行 library() 函数时,我收到以下错误消息。

> library(dplyr) 

**Error: package or namespace load failed for ‘dplyr’ in inDL(x, as.logical(local), as.logical(now), ...)
unable to load shared object 'C:/Program Files/R/R-3.6.2/library/stats/libs/x64/stats.dll':
  LoadLibrary failure:  The specified module could not be found.
In addition: Warning message:
package ‘dplyr’ was built under R version 3.6.3**


And when I first open R, this is what it looks like

**R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (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.
    Error: package or namespace load failed for ‘stats’ in inDL(x, as.logical(local), as.logical(now), 
     ...):
 unable to load shared object 'C:/Program Files/R/R-3.6.2/library/stats/libs/x64/stats.dll':
  LoadLibrary failure:  The specified module could not be found.
   During startup - Warning message:
   package ‘stats’ in options("defaultPackages") was not found 
   Error in inDL(x, as.logical(local), as.logical(now), ...) : 
  unable to load shared object 'C:/Program Files/R/R-3.6.2/library/stats/libs/x64/stats.dll':
  LoadLibrary failure:  The specified module could not be found.**

我无法执行任何我认为应该有效的先前分析。对此问题的任何帮助将不胜感激。

【问题讨论】:

    标签: r dplyr package


    【解决方案1】:

    一个可能的解释是库的路径在 R 中被错误记录。命令 .libPaths() 将列出 R 在查找库时搜索的当前路径。检查此输出是否与您认为要安装软件包的文件夹匹配。

    至少您应该会在此列表中看到 R 的安装目录。在 Windows 上类似于 "C:/Program Files/R/R-3.6.2/library"

    如果您没有看到任何路径/您希望看到的路径,那么您可以使用以下方法添加其他路径:

    .libPaths( c( .libPaths(), "path/to/installed/packages") )
    

    如果您确定这是原因,请查看this questionthis one。这两个链接都涉及对库路径进行永久更改。

    【讨论】:

    • 感谢西蒙的帮助。这就是我得到的。 > .libPaths() [1] "C:/Users/Sterling L. Wright/Documents/R/win-library/3.6" [2] "C:/Program Files/R/R-3.6.2/library" 现在我试过你的代码建议。但是当我这样做时,这里是输出。 > .libPaths( c( .libPaths(), "C:~/Documents/R/win-library/3.6")) > library(dplyr) 错误:inDL(x, as .logical(local), as.logical(now), ...): 无法加载共享对象'C:/Program Files/R/R-3.6.2/library/stats/libs/x64/stats.dll' :LoadLibrary 失败:找不到指定的模块。
    • 我不确定这是否有帮助,但是当我输入 sessionInfo() > sessionInfo() Error in La_library() : LAPACK routines cannot be loaded In addition: Warning message: In La_library() : unable to load shared object 'C:/PROGRA~1/R/R-40~1.2/modules/x64/lapack.dll': LoadLibrary failure: The specified module could not be found.
    • 这可能不是包错误。重新安装可能是最简单的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-11
    • 1970-01-01
    • 2011-09-23
    • 1970-01-01
    • 2021-06-18
    相关资源
    最近更新 更多