R (Ubuntu) - 无法安装软件包 "readr" 和 "eurostat"

R (Ubuntu) - Can't install packages "readr" and "eurostat"

我在R中安装"eurostats"包时遇到问题。分解问题后,我推断问题出在"readr"包上。尝试安装它,出现这种情况:

* installing *source* package ‘readr’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG   -I"/home/shiny/R/x86_64-pc-linux-gnu-library/3.3/Rcpp/include" -I"/home/shiny/R/x86_64-pc-linux-gnu-library/3.3/BH/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c Collector.cpp -o Collector.o

之后,终端就冻结了,就好像它处于活动状态一样,但对此没有任何影响 happens.Prior,我有点用语言环境设置来解决(如果有帮助就提一下)。我能够安装其他软件包。

我的R和Linux详情如下:

sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
[1] httr_1.2.1      R6_2.2.0        tools_3.3.2     withr_1.0.2    
[5] curl_2.2        memoise_1.0.0   git2r_0.16.0    digest_0.6.10  
[9] devtools_1.12.0

有人可以帮我吗?

您那台机器上的 RAM 不足。所以你有两个选择:

  • 继续您正在做的事情并尝试从源代码编译,这将需要更多内存并且很可能会失败

  • 安装一个预构建的二进制文件 (!!) 这样您就不必首先编译

最简单的方法是这样的(当我在 Ubuntu 16.04 的 Docker 实例中执行此操作时,我只显示命令,而不显示输出,我在Docker其中账号为root;否则在前面加sudo)

apt-get update     # refresh
apt-get install software-properties-common
add-apt-repository -y "ppa:marutter/rrutter"
add-apt-repository -y "ppa:marutter/c2d4u"
apt-get update     # now with new repos
apt-get install r-cran-readr

and voila 你有 readr 包。现在继续处理未打包为二进制文件的 eurostat,但由于其 C++ 代码,可能不需要 readr 所需的更多资源。

我的 raspberry pi 也遇到了同样的问题。解决方法是增加交换的大小(在我的例子中为 1Gb)。以下是步骤:

sudo swapon -s #get size and filename
sudo swapoff -a #stop the actual swaps
sudo fallocate -l 1g swap2 #allocate 1Gb for the swapfile
sudo mkswap swap2
sudo swapon swap2

启动 R 并安装您的软件包。

如果您需要返回到之前的配置:

sudo swapoff -a
sudo rm swap2
sudo swapon your-previous-swap