bir*_*ird 3 linux r rstudio-server terra
我正在Rstudio server
远程服务器上使用,并且已经安装了一些软件包。
当我尝试加载类似raster
或terra
using 之类的库时Rstudio server
,出现错误:
> library(terra)\n\nError: package or namespace load failed for \xe2\x80\x98terra\xe2\x80\x99 in dyn.load(file, DLLpath = DLLpath, ...):\n unable to load shared object '/home/pearless/R/x86_64-pc-linux-gnu-library/4.1/terra/libs/terra.so':\n libproj.so.15: cannot open shared object file: No such file or directory\n\n> library(raster)\n\nError: package or namespace load failed for \xe2\x80\x98raster\xe2\x80\x99 in dyn.load(file, DLLpath = DLLpath, ...):\n unable to load shared object '/home/pearless/R/x86_64-pc-linux-gnu-library/4.1/terra/libs/terra.so':\n libproj.so.15: cannot open shared object file: No such file or directory\n
Run Code Online (Sandbox Code Playgroud)\n请注意,使用Rstudio server
以下命令加载其他包tidyverse
效果很好:
> library(tidyverse)\n\n\xe2\x94\x80\xe2\x94\x80 Attaching packages \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80 tidyverse 1.3.1 \xe2\x94\x80\xe2\x94\x80\n\xe2\x9c\x93 ggplot2 3.3.5 \xe2\x9c\x93 purrr 0.3.4\n\xe2\x9c\x93 tibble 3.1.6 \xe2\x9c\x93 forcats 0.5.1\n\xe2\x9c\x93 readr 2.0.2 \n\xe2\x94\x80\xe2\x94\x80 Conflicts \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80 tidyverse_conflicts() \xe2\x94\x80\xe2\x94\x80\nx dplyr::filter() masks stats::filter()\nx dplyr::lag() masks stats::lag()\n
Run Code Online (Sandbox Code Playgroud)\nR
当我在服务器中使用控制台而不使用 时Rstudio server
,可以毫无问题地加载raster
和包:terra
$ R\n\nR version 4.1.1 (2021-08-10) -- "Kick Things"\nCopyright (C) 2021 The R Foundation for Statistical Computing\nPlatform: x86_64-pc-linux-gnu (64-bit)\n\nR is free software and comes with ABSOLUTELY NO WARRANTY.\nYou are welcome to redistribute it under certain conditions.\nType 'license()' or 'licence()' for distribution details.\n\n Natural language support but running in an English locale\n\nR is a collaborative project with many contributors.\nType 'contributors()' for more information and\n'citation()' on how to cite R or R packages in publications.\n\nType 'demo()' for some demos, 'help()' for on-line help, or\n'help.start()' for an HTML browser interface to help.\nType 'q()' to quit R.\n\n> library(terra)\nterra version 1.4.11\n\n> library(raster)\nLoading required package: sp\n
Run Code Online (Sandbox Code Playgroud)\n我该如何解决这个问题,以便我也可以加载这些包Rstudio server
?
根据@user2554330的评论更新:
\n.libPaths()
两者给出完全相同的结果。
Sys.getenv("PATH")
并在服务器控制台Sys.getenv("LD_LIBRARY_PATH")
中给出不同的结果-似乎没有看到大多数路径变量。我在服务器中运行和in ,并将结果复制并分别粘贴到和中。执行此操作后,当我加载库和.R
Rstudio
Rstudio server
pth = Sys.getenv("PATH")
ld_pth = Sys.getenv("LD_LIBRARY_PATH")
R
Sys.setenv(PATH = "result_of_pth")
Sys.setenv(PATH = "result_of_ld_pth")
Rstudio server
raster
terra
是的,两者都使用相同的用户名运行。
\n小智 6
根据robert-hijmans的回复,我通过添加以下内容解决了这个问题:
apt-get -y update && apt-get install -y \
libudunits2-dev \
libgdal-dev \
libgeos-dev \
libproj-dev \
libmysqlclient-dev
Run Code Online (Sandbox Code Playgroud)