简体   繁体   English

如何在离线的Debian机器上安装一个R package?

[英]How can I install a R package on a offline Debian machine?

I have an Debian VM which is not connected to inte.net.我有一个 Debian 虚拟机,它没有连接到 inte.net。 Yet, I can still scp any file from my local machine which does have inte.net connection.然而,我仍然可以从具有 inte.net 连接的本地计算机上 scp 任何文件。 To provide a little bit context, I am trying to host an shiny app on the VM.为了提供一点上下文,我尝试在 VM 上托管一个 shiny 应用程序。

I can still install an old version of R 3.1.1 with the "apt-get" command:我仍然可以使用“apt-get”命令安装旧版本的 R 3.1.1:

sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev

Yet, still can't find the "shiny" package when check the list:然而,在查看列表时仍然找不到“闪亮的”package:

sudo apt-cache search "^r-.*" | sort

So, I am thinking whether I could just scp the "shiny.tar.gz" to the VM and install the package locally?所以,我在想我是否可以将“shiny.tar.gz”scp 到虚拟机并在本地安装 package? How could I install any R package offline?我怎么能离线安装任何 R package?

I have tried somethings like:我试过类似的东西:

install.packages('/home/mli/R/dir_pkg/shiny/shiny_0.13.2.tar.gz', repos = NULL, type = "source")

Yet, it didn't go through and error message as below:然而,它没有通过 go 和错误消息如下:

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Error in type == "both" : 
comparison (1) is possible only for atomic and list types
Calls: install.packages
Execution halted

Then, I tried it with another "R CMD":然后,我用另一个“R CMD”试了一下:

R CMD INSTALL /home/mli/R/dir_pkg/shiny/shiny_0.13.2.tar.gz

I got error message telling me that dependencies is missing:我收到错误消息,告诉我缺少依赖项:

* installing to library ‘/home/mli/R/x86_64-pc-linux-gnu-library/3.1’
ERROR: dependencies ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’, ‘htmltools’, ‘R6’ are not available for package ‘shiny’
* removing ‘/home/mli/R/x86_64-pc-linux-gnu-library/3.1/shiny’

How can I successfully install shiny package from source?如何从源代码成功安装 shiny package? Should I go ahead to install all dependencies and dependencies of dependencies first?我是否应该提前 go 来安装所有依赖项和依赖项的依赖项?

Shiny has a few package dependencies, and "R CMD INSTALL" won't find them for you, so you need to get them manually. Shiny有一些软件包依赖项,“ R CMD INSTALL”将不会为您找到它们,因此您需要手动获取它们。 According to the description of shiny, it's dependencies are: 'Rcpp', 'httpuv', 'mime', 'jsonlite', 'xtable', 'digest', 'htmltools', 'R6'. 根据Shiny的描述,它的依赖项为:'Rcpp','httpuv','mime','jsonlite','xtable','digest','htmltools','R6'。 So first, get the packages from cran (below are current versions, but they do change over time. Note below is for the computer connected to the internet, you'll need to scp these to the offline computer before continuing): 因此,首先,请从cran获取软件包(以下是当前版本,但是它们会随着时间的推移而变化。请注意,以下是针对连接到Internet的计算机的信息,在继续之前,您需要将它们打包到脱机计算机中):

wget https://cran.r-project.org/src/contrib/Rcpp_0.12.4.tar.gz 
wget https://cran.r-project.org/src/contrib/httpuv_1.3.3.tar.gz 
wget https://cran.r-project.org/src/contrib/mime_0.4.tar.gz 
wget https://cran.r-project.org/src/contrib/jsonlite_0.9.19.tar.gz 
wget https://cran.r-project.org/src/contrib/digest_0.6.9.tar.gz 
wget https://cran.r-project.org/src/contrib/htmltools_0.3.5.tar.gz 
wget https://cran.r-project.org/src/contrib/R6_2.1.2.tar.gz 
wget https://cran.r-project.org/src/contrib/shiny_0.13.2.tar.gz

Then go through them in that same order with R CMD INSTALL. 然后使用R CMD INSTALL按照相同的顺序进行处理。 eg: 例如:

R CMD INSTALL Rcpp_0.12.4.tar.gz

Once all the dependencies are there, R CMD INSTALL should let you install shiny. 一旦所有依赖项都存在,R CMD INSTALL应该让您安装Shiny。

To install some package-offline on Debian you can use apt-offline : 要在Debian上安装一些package-offline,可以使用apt-offline

apt-offline can fully update and upgrade an APT based distribution without connecting to the network, all of it transparent to APT. apt-offline可以完全更新和升级基于APT的发行版,而无需连接到网络,所有这些对APT都是透明的。

apt-offline can be used to generate a signature on a machine (with no network). apt-offline可用于在计算机(无网络)上生成签名。 This signature contains all download information required for the APT database system. 该签名包含APT数据库系统所需的所有下载信息。 This signature file can be used on another machine connected to the internet (which need not be a Debian box and can even be running windows) to download the updates. 该签名文件可以在连接到互联网的另一台计算机上使用(不必是Debian盒子,甚至可以运行Windows)以下载更新。 The downloaded data will contain all updates in a format understood by APT and this data can be used by apt-offline to update the non-networked machine. 下载的数据将包含APT可以理解的格式的所有更新,并且apt-offline可以使用此数据来更新未联网的计算机。

Install apt-offline on the offline os (Debian) then type the following command (to import missing keys) : 在离线os(Debian)上安装apt-offline ,然后键入以下命令(以导入丢失的密钥):

sudo apt-key exportall | sudo gpg --no-default-keyring --import --keyring /etc/apt/trusted.gpg

Then you need to get the signature of your_package_name : 然后,您需要获取your_package_name的签名:

apt-offline set debian-install.sig --install-packages your_package_name

Next step ,Upload debian-install.sig to the on-line system and download required files. 下一步,将debian-install.sig上载到在线系统并下载所需的文件。

apt-offline get debian-install.sig --bundle debian-install.zip 

Upload debian-install.zip file to the off-line system, install it using apt-offline utility to update APT database. 将debian-install.zip文件上传到离线系统,使用apt-offline实用程序进行安装以更新APT数据库。

sudo apt-offline install debian-install.zip 

install the specified packages your_package_name : 安装指定的包your_package_name

sudo apt-get install your_package_name

You can download your package using windows machine tuto 您可以使用Windows Machine Tuto下载软件包

You are in a pickle. 你在泡菜里 The R package mechanism expects you to be connected to get dependencies. R包机制希望您进行连接以获取依赖关系。 That said, you can get some help: 也就是说,您可以获得一些帮助:

R> AP <- available.packages(contrib.url(options("repos")$repos[1]))
R> revs <- tools::package_dependencies("shiny", AP, recursive=TRUE)[[1]]
R> revs
 [1] "methods"   "utils"     "httpuv"    "mime"     
 [5] "jsonlite"  "xtable"    "digest"    "htmltools"
 [9] "R6"        "Rcpp"      "tools"     "stats"    
R> 

You can now look into AP again and feed this into download.packages() . 现在,您可以再次查看AP ,并将其输入到download.packages()

Also, several (all ?) of these are in a newer Debian distro so you could use apt-get in download-mode (maybe using apt-offline as suggested in the other question). 另外,其中的几个(全部?)都位于较新的 Debian发行版中,因此您可以在下载模式下使用apt-get (也许按照另一个问题的建议使用apt-offline )。

Lastly, we do offer a Docker container for shiny so if you use that on your VM you don't need anything else. 最后,我们确实提供了一个用于发光Docker容器,因此,如果您在VM上使用它,则不需要其他任何东西。

sudo apt-get update sudo apt-get更新

sudo apt-get install r-cran-digest 须藤apt-get install r-cran-digest


I can`t belive that it was so easy. 我不敢相信这是如此的容易。 I spent a long time searching and got only bad answers. 我花了很长时间搜索,但得到的答案很差。 This commands just solve everything. 此命令可以解决所有问题。 I used it on trisquel 我在trisquel上用过

after checking all the answers on stackoverflow, I am not able to find exactly how to to install r-base on Debian/linux system.在检查了 stackoverflow 上的所有答案后,我无法准确找到如何在 Debian/linux 系统上安装 r-base。 So, I have tried myself and able to run by below steps:所以,我已经尝试过自己并且能够通过以下步骤运行:

Run below command on inte.net working Linux machine in a custom folder.

apt-get download r-base r-base-core r-recommended libmpfr6 libisl19 cpp cpp-8 cpp-4  gcc cpp-8 binutils-common libbinutils binutils-x86-64-linux-gn  gfortran linux-libc-dev g++ g++-8 libstdc make dpkg-dev perl-base perl-modules-5.28 libperl5.28 ibgdbm-compat4 zip  unzip  libpaper-utils xdg-utils libblas3 libblas.so.3 libcairo2 libcurl4 libgfortran5 libglib2.0-0 libice6 libicu63 libjpeg62-turbo liblapack3 liblapack.so.3 libpango-1.0-0 libpangocairo-1.0-0 libpng16-16 libsm6 libtcl8.6 libtiff5 libtk8.6 libx11-6 libxext6 libxss1 libxt6 ucf libfontconfig1 libfreetype6 libpixman-1-0 libxcb-render0 libxcb-shm0 libxcb1 libxrender1 libgssapi-krb5-2 libk5crypto3 libkrb5-3 libldap-2.4-2 libnghttp2-14 libpsl5 librtmp1 libssh2-1 libbsd0  x11-common fontconfig  libfribidi0 libthai0 libcairo2:amd64 libfontconfig1 libfreetype6 libpango-1.0-0:amd64 libpangoft2-1.0-0 fontconfig-config libkeyutils1 libkrb5support0 libkeyutils1 libkrb5support0 libkeyutils1 libkrb5support0 libsasl2-2 libldap-common fontconfig-config libharfbuzz0b libpaper1 libsasl2-modules-db libthai-data libdatrie1 libwebp6 libjbig0 libxft2 libx11-data libxau6 libxdmcp6 fonts-dejavu-core ttf-bitstream-vera fonts-liberation libgraphite2-3 lsb-base sensible-utils  r-cran-boot r-cran-cluster r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mgcv r-cran-nlme r-cran-rpart r-cran-survival r-cran-mass r-cran-class r-cran-nnet r-cran-spatial r-cran-codetools r-cran-matrix

This will create debian files inside the folder.

`Execute tar -zcf folder.tar.gz folder`

Copy this folder.tar.gz in offline computer and execute below command after going inside the folder.将此文件夹.tar.gz 复制到离线计算机中,进入文件夹后执行以下命令。

 dpkg -i *

Now check R in your system by typing现在通过键入检查系统中的 R

R --version

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

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