简体   繁体   English

Jupyter 笔记本:Package 或 loadNamespace 中“插入符号”的命名空间加载失败

[英]Jupyter notebook: Package or namespace load failed for 'caret' in loadNamespace

I was originally going to ask the following question but I figured it out myself and decided to post the following question and answer in case it might help someone with the same issue:我原本打算问以下问题,但我自己想通了,并决定发布以下问题和答案,以防它可能对遇到同样问题的人有所帮助:

I'm currently working on a project in Jupyter Notebook using R.我目前正在使用 R 在 Jupyter Notebook 中开展一个项目。

Everything was working fine until I try to load caret with library(caret) and I get the following error message:一切正常,直到我尝试使用library(caret)加载插入符号并收到以下错误消息:


Error: package or namespace load failed for 'caret' in loadNamespace(j <- i[[1L]], c(lib.loc, > > .libPaths()), versionCheck = vI[[j]]):
there is no package called 'codetools'
Traceback:

1. library(caret)
2. tryCatch({
.     attr(package, "LibPath") <- which.lib.loc
.     ns <- loadNamespace(package, lib.loc)
 .     env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)
 . }, error = function(e) {
 .     P <- if (!is.null(cc <- conditionCall(e))) 
 .         paste(" in", deparse(cc)[1L])
 .     else ""
 .     msg <- gettextf("package or namespace load failed for %s%s:\n %s", 
 .         sQuote(package), P, conditionMessage(e))
 .     if (logical.return) 
 .         message(paste("Error:", msg), domain = NA)
 .     else stop(msg, call. = FALSE, domain = NA)
 . })
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. value[[3L]](cond)
6. stop(msg, call. = FALSE, domain = NA)

I've tried unistalling and re-installing caret in RStudio but that didn't help either.我已经尝试在 RStudio 中卸载并重新安装caret ,但这也没有帮助。 What makes this more infuriating is that in my RStudio everything is working fine, it's just Jypyter notebook that is unable to find caret .更令人气愤的是,在我的 RStudio 中一切正常,只是 Jypyter notebook 找不到caret

Here is my session info FYI:这是我的 session 信息仅供参考:

R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 15063)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252 
[2] LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.3.0   lattice_0.20-38

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3        pillar_1.4.2      compiler_3.6.0    plyr_1.8.4       
 [5] base64enc_0.1-3   iterators_1.0.12  tools_3.6.0       digest_0.6.22    
 [9] uuid_0.1-2        jsonlite_1.6      evaluate_0.14     tibble_2.1.3     
[13] gtable_0.3.0      nlme_3.1-142      pkgconfig_2.0.3   rlang_0.4.5      
[17] foreach_1.4.7     IRdisplay_0.7.0   IRkernel_1.0.2    repr_1.0.1       
[21] withr_2.1.2       dplyr_0.8.3       grid_3.6.0        tidyselect_0.2.5 
[25] glue_1.3.1        R6_2.4.1          pbdZMQ_0.3-3      purrr_0.3.3      
[29] magrittr_1.5      scales_1.0.0      codetools_0.2-16  htmltools_0.4.0  
[33] assertthat_0.2.1  timeDate_3043.102 colorspace_1.4-1  munsell_0.5.0    
[37] crayon_1.3.4     
​```

I solved the issue by uninstalling caret with remove.packages("caret") in Jupyter Notebook.我通过在 Jupyter Notebook 中使用remove.packages("caret")卸载caret解决了这个问题。 I also checked that the package was no longer installed in RStudio.我还检查了 package 不再安装在 RStudio 中。

Then, I re-installed caret with install.packages("caret", dependencies = TRUE) in Jupyter notebook.然后,我在 Jupyter 笔记本中使用 install.packages(" caret install.packages("caret", dependencies = TRUE)重新安装了插入符号。

I think what was causing the issue was that somehow Jupyter had not installed caret 's dependent packages.我认为导致问题的原因是 Jupyter 没有安装caret的依赖包。 From the first error message in the question,this was codetools .从问题中的第一条错误消息来看,这是codetools And every time I installed the package named in the error, it came up with another package to install.并且每次我安装错误中命名的package时,它都会想出另一个package来安装。 Which made me think that - of course- it hadn't installed any of the dependencies.这让我觉得——当然——它没有安装任何依赖项。

caret now works in Jupyter Notebook. caret现在可以在 Jupyter Notebook 中使用。

暂无
暂无

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

相关问题 错误:loadNamespace 中“tidyverse”的包或命名空间加载失败 - Error: package or namespace load failed for ‘tidyverse’ in loadNamespace 错误:“ geoR”的程序包或名称空间加载失败:.tcltk的loadNamespace()在.onLoad中失败 - Error: package or namespace load failed for ‘geoR’: .onLoad failed in loadNamespace() for 'tcltk' r编程-loadnamespace中的错误-包或名称空间加载失败 - r programming - error in loadnamespace - package or namespace load failed &gt; library(ez)错误:loadNamespace中&#39;ez&#39;的包或命名空间加载失败 - > library(ez) Error: package or namespace load failed for ‘ez’ in loadNamespace 错误:package 或 loadNamespace 中“EGSEA”的命名空间加载失败(i,c(lib.loc,.libPaths()),versionCheck = vI[[i]]): - Error: package or namespace load failed for ‘EGSEA’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): 错误:程序包或命名空间加载失败 - Error: Package or namespace load failed “ SequentialTranches”的包或名称空间加载失败 - package or namespace load failed for 'SequentialTranches' 安装包时,.onLoad在&#39;rJava&#39;的loadNamespace()中失败 - .onLoad failed in loadNamespace() for 'rJava' when installing a package 无法在 Jupyter Notebook 中加载 processR 包的 `model1` 函数 - Can not load the `model1` function of the processR package in a Jupyter Notebook 错误:包或名称空间加载失败,找不到对象… - Error: package or namespace load failed, object … not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM