简体   繁体   English

R Install.packages失败,并显示“找不到对象错误”

[英]R Install.packages fails with “object not found error”

I am currently trying to install packages on R. On the startup, I get the normal R message with 我目前正在尝试在R上安装软件包。在启动时,我收到了正常的R消息,其中包含

"Error: object 'getw' not found" “错误:找不到对象'getw'”

When I use the install.packages function, I get the same error at the end of the installation, one for each package I tried to install. 当我使用install.packages函数时,在安装结束时会出现相同的错误,我尝试安装的每个软件包都会出现一个错误。

However, when I start R with R --no-init-file I can install packages normally. 但是,当我以R --no-init-file开头R时,我可以正常安装软件包。

I have been fishing around with Rprofile and other initialization settings of R. I have also done clean installs of R, and the message still appears. 我一直在研究Rprofile和R的其他初始化设置。我还完成了R的全新安装,并且消息仍然出现。

Does anyone have an idea about how to remove this error? 有谁知道如何删除此错误? Also, this machine is running Ubuntu 14.04 Trust Tahr. 另外,这台机器正在运行Ubuntu 14.04 Trust Tahr。

This sounds like something is wrong with the .Rprofile file. 听起来好像.Rprofile文件有问题。 There can be more than one such file. 这样的文件可以有多个。 At the beginning of an R session, R first searches for such a file in the working directory, then in the home directory. 在R会话开始时, R首先在工作目录中搜索该文件,然后在主目录中搜索。

You may also want to check if the environment variable R_PROFILE_USER is set (In an R shell, this can be checked with Sys.getenv("R_PROFILE_USER") ). 您可能还需要检查是否设置了环境变量R_PROFILE_USER (在R Shell中,可以使用Sys.getenv("R_PROFILE_USER")进行检查)。 If yes, look at the .Rprofile file in that directory to see if there is any suspicious entry. 如果是,请查看该目录中的.Rprofile文件,以查看是否存在任何可疑条目。

If all fails, make a copy of the .Rprofile file in your home directory and (if applicable) in your working directory with a different name. 如果全部失败,请使用您的其他名称在主目录和(如果适用)工作目录中复制.Rprofile文件。 Then delete the file and try the installation again. 然后删除该文件,然后重试安装。 If this succeeds you can afterwards restore the old .Rprofile file(s) by using the copy/copies that you made before. 如果成功,则可以使用以前制作的副本来还原旧的.Rprofile文件。

I had the same error. 我有同样的错误。 In my case, this was due to a previous partially failed uninstall of the package I was trying to install. 就我而言,这是由于以前我尝试安装的软件包卸载失败而导致的。 Manually removing the partially uninstalled version of the package then allowed intall.packages to succeed. 手动删除软件包的部分卸载版本,然后使intall.packages成功。

Full details: 详细信息:

I had run devtools::install_github(...) which prompted about newer versions of some required packages being available. 我运行过devtools::install_github(...) ,它提示一些必需软件包的较新版本可用。 I opted to install these updated versions in response to the prompt. 我选择安装这些更新的版本以响应提示。 One of these packages (Rcpp) failed to be installed with an error about being unable to remove the older version of that package (presumably due to the file being in use/locked somehow). 这些软件包之一(Rcpp)未能安装,并出现一个错误,提示无法删除该软件包的较早版本(可能是由于文件正在使用/以某种方式锁定)。

When I tried to install a newer version of Rcpp from install.packages, I got the above error. 当我尝试从install.packages安装Rcpp的较新版本时,出现上述错误。

After investigating various things, I eventually ran .libPaths() which output the location my packages are installed. 在研究了各种内容之后,我最终运行了.libPaths() ,它输出了我的软件包的安装位置。 I went to this folder, found the Rcpp subfolder, which was mostly empty except one file (Rcpp.dll) - presumably the file that failed to be deleted before. 我转到此文件夹,找到Rcpp子文件夹,该子文件夹几乎是空的,除了一个文件(Rcpp.dll)-大概是以前删除失败的文件。 I deleted this file manually and deleted the Rcpp folder. 我手动删除了此文件,并删除了Rcpp文件夹。

I then retried install.packages(...) which now succeeded. 然后,我重试了install.packages(...) ,现在成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM