【发布时间】:2019-06-21 13:08:05
【问题描述】:
我一直在运行一个 bash 脚本(在 Ubuntu 下),它调用并运行一些 R 脚本以使用 ggplot2 绘制一些地图。由于它是一个生产系统,我不会更新任何新的 R 或软件包版本。但最近我尝试安装 plotly 并输出错误消息。
现在,当尝试运行脚本时(通过浏览器调用 php 网页;这在很长一段时间内都运行良好),蜡笔包的错误会停止并退出脚本而不绘制地图。
'/usr/lib/R/bin/R --slave --no-restore --no-save --no-restore --file=./RAMS-mapa-onades-zones-manual.R'
Loading required package: sp
Loading required package: methods
Checking rgeos availability: TRUE
Error : .onLoad failed in loadNamespace() for 'pillar', details:
call: loadNamespace(name)
error: there is no package called 'crayon'
Error: package or namespace load failed for 'ggplot2'
Execution halted
但如果我从终端运行或使用 RStudio 服务器运行 crayon 包,ggplot2 也会正确加载,并生成地图。
crayon 包(位于 /home/meteo/R/i686-pc-linux-gnu-library/3.1)称为
library("crayon", lib.loc= c("/home/meteo/R/i686-pc-linux-gnu-library/3.1", "/usr/local/lib/R/site-library", "/usr/lib/R/library"))
Rstudio 服务器上的 R 会话信息:
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu precise (12.04.5 LTS)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C LC_COLLATE=C LC_MONETARY=C LC_MESSAGES=C
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] crayon_1.3.4 rgdal_0.9-1 rgeos_0.3-8 raster_2.3-24 gpclib_1.5-5 mapproj_1.2-2 maps_2.3-9
[8] stringr_0.6.2 plyr_1.8.1 ggplot2_3.2.0 maptools_0.8-34 sp_1.2-3
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 magrittr_1.5 tidyselect_0.2.5 munsell_0.5.0 colorspace_1.2-4 lattice_0.20-33 R6_2.4.0
[8] rlang_0.3.4 dplyr_0.8.1 tools_3.2.2 gtable_0.1.2 withr_2.1.2 digest_0.6.8 lazyeval_0.2.2
[15] assertthat_0.2.1 tibble_2.1.3 purrr_0.3.2 glue_1.3.1 labeling_0.3 pillar_1.4.1 scales_1.0.0
[22] foreign_0.8-66 pkgconfig_2.0.2
可能是版本冲突?如何检查?
【问题讨论】:
-
如果我理解正确,当您运行
/RAMS-mapa-onades-zones-manual.R时会发生错误。该脚本是否包括像library("crayon", lib.loc= c("/home/meteo/....这样加载蜡笔包?当从/RAMS-mapa-onades-zones-manual.R调用/添加到/RAMS-mapa-onades-zones-manual.R时,您能否给出print(.libPahts())的输出? -
嗨@BigDataScientist。
print(.libPaths())给出错误消息 > print(.libPahts())Error in print(.libPahts()) : error in evaluating the argument 'x' in selecting a method for function 'print': Error: could not find function ".libPahts" -
如果我从 RStudio 服务器运行脚本,它工作正常,无需调用蜡笔。如果我(在浏览器窗口内)运行一个调用具有 R CMD BATCH script.R 的 bash 脚本的 php 脚本,那么它会因有关蜡笔的这条消息而崩溃。我添加了对蜡笔的显式调用以尝试解决问题,但它没有奏效。
-
sry 错字,是
.libPaths(),... -
您的会话信息表明您使用的是 R 3.2.2,但您的库路径指向 R 3.1?您可能应该使用
library而不明确指出路径,并为您实际使用的 R 版本安装任何缺少的包。