简体   繁体   English

错误:package 或 ggplot2 和 data.table 的命名空间加载失败

[英]Error: package or namespace load failed for ggplot2 and for data.table

I am not able to open install the ggplot2 and data.table packages.我无法打开安装 ggplot2 和 data.table 软件包。 It gives me the following error (example for ggplot2)它给了我以下错误(ggplot2 的示例)

> library(ggplot2)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called ‘Rcpp’
Error: package or namespace load failed for ‘ggplot2’

I was able to work fine with these 2 packages before I closed my R session. Now it shows me this error each time I try to run it.在我关闭我的 R session 之前,我能够很好地使用这两个包。现在每次我尝试运行它时它都会显示这个错误。

I have also tried to remove and re-install it, but without success.我也尝试过删除并重新安装它,但没有成功。

remove.packages(c("ggplot2", "data.table"))
install.packages('ggplot2', dep = TRUE)
install.packages('data.table', dep = TRUE)

I am not sure what's wrong我不确定出了什么问题

This solved the issue:这解决了这个问题:

remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)
install.packages('data.table', dependencies = TRUE)

After a wild goose chase with tons of Google searches and burteforce attempts, I think I found how to solve this problem.经过大量的 Google 搜索和 burteforce 尝试后,我想我找到了解决这个问题的方法。

Steps undertaken to solve the problem:为解决问题而采取的步骤:

  1. Uninstall R卸载 R
  2. Reinstall R重新安装 R
  3. Install ggplot with the dependencies argument to install.packages set to TRUE安装 ggplot,将 install.packages 的依赖项参数设置为 TRUE

    install.packages("ggplot2",dependencies = TRUE)

  4. The above step still does NOT include the Rcpp dependency so that has to be manually installed using the following command上述步骤仍然不包括 Rcpp 依赖项,因此必须使用以下命令手动安装

    install.packages("Rcpp")

However, while the above command successfully downloads Rcpp, for some reason, it fails to explode the ZIP file and install it in my R's library folder citing the following error:但是,虽然上述命令成功下载了 Rcpp,但由于某种原因,它无法分解 ZIP 文件并将其安装在我的 R 的库文件夹中,并引用以下错误:

package 'Rcpp' successfully unpacked and MD5 sums checked Warning in install.packages : unable to move temporary installation 'C:\\Root_Prgs\\Data_Science_SW\\R\\R-3.2.3\\library\\file27b8ef47b6d\\Rcpp' to 'C:\\Root_Prgs\\Data_Science_SW\\R\\R-3.2.3\\library\\Rcpp'包 'Rcpp' 成功解包并检查 MD5 总和 install.packages 中的警告:无法将临时安装 'C:\\Root_Prgs\\Data_Science_SW\\R\\R-3.2.3\\library\\file27b8ef47b6d\\Rcpp' 移动到 'C:\\Root_Prgs\\ Data_Science_SW\\R\\R-3.2.3\\library\\Rcpp'

The downloaded binary packages are in C:\\Users\\MY_USER_ID\\AppData\\Local\\Temp\\Rtmp25XQ0S\\downloaded_packages下载的二进制包在 C:\\Users\\MY_USER_ID\\AppData\\Local\\Temp\\Rtmp25XQ0S\\downloaded_pa​​ckages

  1. Note that the above output says "Warning" but actually, it is an indication of failure to install the Rcpp package successfully within the repository.请注意,上面的输出表示“警告”,但实际上,这表明在存储库中无法成功安装 Rcpp 包。 I then used the Tools-->Install packages--> From ZIP file and pointed to the location of the "downloaded binary packages" in the message above -然后我使用工具-->安装包-->从ZIP文件并指向上面消息中“下载的二进制包”的位置-

C:\\Users\\MY_USER_ID\\AppData\\Local\\Temp\\Rtmp25XQ0S\\downloaded_packages\\Rcpp_0.12.3.zip

  1. This led to successful installation of Rcpp in my R\\R-3.2.3\\library folder, thereby ensuring that Rcpp is now available when I attempt to load the library for ggplot2.这导致在我的 R\\R-3.2.3\\library 文件夹中成功安装了 Rcpp,从而确保当我尝试加载 ggplot2 库时 Rcpp 现在可用。 I could not do this step in the past because my previous installation of R would throw error stating that Rcpp cannot be imported.过去我无法执行此步骤,因为我之前安装的 R 会抛出错误,指出无法导入 Rcpp。 However, the same command worked after I uninstalled and reinstalled R, which is ODD.但是,在我卸载并重新安装 R(ODD)后,相同的命令起作用了。

    install.packages("C:/Users/MY_USER_ID/AppData/Local/Temp/Rtmp25XQ0S/downloaded_packages/Rcpp_0.12.3.zip", repos = NULL, type = "win.binary") package 'Rcpp' successfully unpacked and MD5 sums checked` install.packages("C:/Users/MY_USER_ID/AppData/Local/Temp/Rtmp25XQ0S/downloaded_pa​​ckages/Rcpp_0.12.3.zip", repos = NULL, type = "win.binary") package 'Rcpp' 成功解包和 MD5 总和已检查`

  2. I was finally able to load the ggplot2 library successfully.我终于能够成功加载 ggplot2 库。

    library(ggplot2)

I also faced the same problem and我也遇到了同样的问题

remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)

these commands did not work for me.这些命令对我不起作用。 What I found was that it was showing a warning message that it could not move temporary installation C:\\Users\\User_name\\Documents\\R\\win-library\\3.3\\abcd1234\\Rcpp to C:\\Users\\User_name\\Documents\\R\\win-library\\3.3\\Rcpp .我发现它显示了一条警告消息,提示它无法将临时安装C:\\Users\\User_name\\Documents\\R\\win-library\\3.3\\abcd1234\\RcppC:\\Users\\User_name\\Documents\\R\\win-library\\3.3\\Rcpp

I downloaded the Rcpp zip file from the link given and unziped it and copied it inside C:\\Users\\User_name\\Documents\\R\\win-library\\3.3 and then我从给定的链接下载了 Rcpp zip 文件并将其解压缩并将其复制到C:\\Users\\User_name\\Documents\\R\\win-library\\3.3 ,然后

library(Rcpp)
library(ggplot2) 

worked.工作。 I did not have to uninstall R. Hope this helps.我不必卸载 R。希望这会有所帮助。

Faced same issue and solved by :面临同样的问题并通过以下方式解决:

remove.packages("ggplot2")
install.packages('ggplot2', dependencies = TRUE)

when you see当你看到

Do you want to install from sources the package which needs compilation?你想从源代码安装需要编译的包吗? (Yes/no/cancel) (是/否/取消)

answer no回答没有

Try this:试试这个:

install.packages('Rcpp')
install.packages('ggplot2')
install.packages('data.table')

I tried the steps mentioned in the earlier posts but without any success.我尝试了之前帖子中提到的步骤,但没有成功。 However, what worked for me was uninstalling R completely and then deleting the R folder which files in the documents folder, so basically everything do with R except the scripts and work spaces I had saved.但是,对我有用的是完全卸载 R,然后删除 R 文件夹中的文档文件夹中的文件,所以基本上除了我保存的脚本和工作空间之外的所有内容都与 R 相关。 I then reinstalled R and ran然后我重新安装了 R 并运行

remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)
install.packages('data.table', dependencies = TRUE)

This rather crude method somehow worked for me.这种相当粗糙的方法对我有用。

I tried all the listed solutions above but nothing worked.我尝试了上面列出的所有解决方案,但没有任何效果。 This is what worked for me.这对我有用。

  1. Look at the complete error message which you get when you use library(ggplot2).查看使用 library(ggplot2) 时获得的完整错误消息。
  2. It lists a couple of packages which are missing or have errors.它列出了几个丢失或有错误的包。
  3. Uninstall and reinstall them.卸载并重新安装它们。
  4. ggplot should work now with a warning for version. ggplot 现在应该可以使用版本警告。

These steps work for me:这些步骤对我有用:

  1. Download the Rcpp manually from WebSite ( https://cran.r-project.org/web/packages/Rcpp/index.html )从网站 ( https://cran.r-project.org/web/packages/Rcpp/index.html ) 手动下载 Rcpp
  2. unzip the folder/files to "Rcpp" folder将文件夹/文件解压缩到“Rcpp”文件夹
  3. Locate the "library" folder under R install directory Ex: C:\\R\\R-3.3.1\\library找到R安装目录下的“library”文件夹例如:C:\\R\\R-3.3.1\\library
  4. Copy the "Rcpp" folder to Library folder.将“Rcpp”文件夹复制到库文件夹。

Good to go!!!好去!

library(Rcpp)
library(ggplot2) 

对我来说,我必须从 brew brew uninstall --force R ,然后转到R 网站并从那里下载并安装它

I had this same problem, but when running in a jupyter R notebook in an Anaconda environment.我遇到了同样的问题,但是在 Anaconda 环境中的 jupyter R notebook 中运行时。

The problem presented in such a way that any R notebook opened would instantly die and would not allow cell execution.以这样一种方式提出的问题是,任何打开的 R 笔记本都会立即死亡,并且不允许单元执行。 The error would show up with each failed automated attempt to start the kernel:每次失败的自动启动内核尝试都会出现错误:

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called ‘Rcpp’

To solve this, I ran as admin/sudo: conda install -cr r-rcpp , restarted the kernel, and everything was back to normal.为了解决这个问题,我以 admin/sudo 身份运行: conda install -cr r-rcpp ,重新启动内核,一切恢复正常。

I had the same problem with the package "tidyverse".我对“tidyverse”包有同样的问题。 I solved the problem with 1. uninstalling the package "Rcpp" and "tidyverse" 2. reinstalling "Rcpp" and answering the following questions during the installation process:我通过1.卸载包“Rcpp”和“tidyverse” 2.重新安装“Rcpp”并在安装过程中回答以下问题解决了问题:

Do you want to install from sources the package which needs compilation? (Yes/no/cancel)

with

no
  1. reinstalling "tidyverse".重新安装“tidyverse”。

Sorry for joining the party late, You can install any package in RStudio by downloading the zip file from the CRAN website and running the below snippet in the console,很抱歉迟到了,您可以通过从CRAN网站下载 zip 文件并在控制台中运行以下代码片段,在 RStudio 中安装任何 package,

install.packages('~/Downloads/Rcpp_1.0.8.tgz', repos = NULL, type = 'source')

暂无
暂无

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

相关问题 PowerBI Desktop 和 R 错误:“ggplot2”的包或命名空间加载失败 - PowerBI Desktop and R Error: package or namespace load failed for 'ggplot2' slidify + data.table(ggplot2)错误 - slidify + data.table( ggplot2) error 错误:“ggplot2”的包或命名空间加载失败:包“ggplot2”是在 R 4.0.0 之前安装的:请重新安装执行停止 - Error: package or namespace load failed for 'ggplot2': package 'ggplot2' was installed before R 4.0.0: please re-install it Execution halted 加载 ggplot2 时抛出错误:package 或命名空间加载失败....没有 package 称为“颜色空间” - Loading ggplot2 throwing the Error: package or namespace load failed .... there is no package called ‘colorspace’ 错误:library.dynam(lib, package, package.lib) 中“data.table”的包或命名空间加载失败:找不到共享对象“datatable.so” - Error: package or namespace load failed for ‘data.table’ in library.dynam(lib, package, package.lib): shared object ‘datatable.so’ not found 错误:程序包或命名空间加载失败 - Error: Package or namespace load failed ggplot2 无法加载,出现“rlang”包错误 - ggplot2 fails to load, with 'rlang' package error 转换简单的ggplot2代码以使用data.table - Converting simple ggplot2 code to use data.table 错误 - 使用ggrepel包在ggplot2中显示数据 - Error - Visualisation data in ggplot2 with ggrepel package library(data.table)中的错误:没有名为“ data.table”的软件包 - Error in library(data.table) : there is no package called 'data.table'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM