2016-04-22 77 views
4
我有一些麻煩更新R.這裏後,在CentOS R中安裝軟件包

是的,當我嘗試R中安裝一個軟件包會發生什麼一個例子:麻煩:網絡程序無法加載

> install.packages("ggplot2") 
Installing package into '/home/albers/R/x86_64-pc-linux-gnu-library/3.2' 
(as 'lib' is unspecified) 
--- Please select a CRAN mirror for use in this session --- 
Error in download.file(url, destfile = f, quiet = TRUE) : 
    internet routines cannot be loaded 
In addition: Warning message: 
In download.file(url, destfile = f, quiet = TRUE) : 
    unable to load shared object '/usr/local/lib64/R/modules//internet.so': 
    /usr/local/lib64/R/modules//internet.so: undefined symbol: curl_multi_wait 
HTTPS CRAN mirror 

1: 0-Cloud [https]    2: Austria [https] 
3: Chile [https]     4: China (Beijing 4) [https] 
5: Colombia (Cali) [https]  6: France (Lyon 2) [https] 
7: France (Paris 2) [https]  8: Germany (M▒nster) [https] 
9: Iceland [https]    10: Mexico (Mexico City) [https] 
11: Russia (Moscow) [https]  12: Spain (A Coru▒a) [https] 
13: Switzerland [https]   14: UK (Bristol) [https] 
15: UK (Cambridge) [https]  16: USA (CA 1) [https] 
17: USA (KS) [https]    18: USA (MI 1) [https] 
19: USA (TN) [https]    20: USA (TX) [https] 
21: USA (WA) [https]    22: (HTTP mirrors) 


Selection: 1 
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib: 
    internet routines cannot be loaded 
Warning message: 
package 'ggplot2' is not available (for R version 3.2.5) 

所以我花了一些時間搜索錯誤消息。我更新了我現在最新版本的捲曲:

$ curl -V 
curl 7.48.0 (x86_64-pc-linux-gnu) libcurl/7.48.0 zlib/1.2.8 
Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp 
Features: IPv6 Largefile libz UnixSockets 

仍然無法安裝軟件包,並且收到相同的錯誤消息。所以我嘗試以下的this post的指示,具體地添加以下命令到我.bash_profile

export LD_LIBRARY_PATH=$TOOLS/curl-7.48.0/lib:$LD_LIBRARY_PATH 

我再次獲得關於R無法加載共享對象相同的錯誤消息。最終,這是一個下載問題,因爲download.file也失敗了。這裏是我的sessionInfo()

R version 3.2.5 (2016-04-14) 
Platform: x86_64-pc-linux-gnu (64-bit) 
Running under: CentOS release 6.2 (Final) 

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

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

我能夠下載與wgetcurl但只要我開始R,我無法下載任何文件。

有沒有人有任何建議我可以解決這個問題?

回答

8

像這樣嘗試。

install.packages("ggplot2", repos="http://cran.cnr.berkeley.edu") 

或只是你安裝它改變你的下載工具到別的東西,即在Linux上,你可以嘗試的wget如下之前。

options(download.file.method = "wget") 

注意,我爲http扔下https。我有一個類似的錯誤...

Selection: 1 
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib: 
    unsupported URL scheme 
Warning message: 
package ‘ggplot2’ is not available (for R version 3.2.3) 

如果你看看從你的問題下面一行的輸出...

Yours 
Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp 
Mine (Also Centos 6) 
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp 

curl缺少https支持。在您的輸出中也有關於curl_multi_wait的錯誤。這是在7.28.0中添加的。

https://curl.haxx.se/libcurl/c/curl_multi_wait.html

如果你需要建立本地捲曲做到這一點

mkdir -p $HOME/curl 
cd $HOME/curl 
git clone https://github.com/curl/curl.git 
cd curl 
bash buildconf 
./configure --prefix=$HOME/libcurl 
make 
make install 

此時你需要設置你的LD_LIBRARY_PATH中的.bash_profile即

export LD_LIBRARY_PATH=$HOME/libcurl/lib:$LD_LIBRARY_PATH 

然後要麼註銷和背部再次或

source ~/.bash_profile 
6

我相信在去年夏天進行R 3.2。*升級之前,我曾回答過類似的問題。使用Ubuntu 12.04的Travis CI有類似的問題。周圍

一個相當簡單的方法就是讓R能夠使用外部wgetcurl二進制你可能有(且必須是HTTPS就緒)下載。因此,嘗試如

R> options("download.file.method"="wget") 

其中,設定時,可以讓我從所需的非HTTPS主機下載你想要的包:

R> install.packages("ggplot2", repos="http://cran.cnr.berkeley.edu") 
Installing package into ‘/usr/local/lib/R/site-library’ 
(as ‘lib’ is unspecified) 
--2016-04-26 18:29:16-- http://cran.cnr.berkeley.edu/src/contrib/ggplot2_2.1.0.tar.gz 
Resolving cran.cnr.berkeley.edu (cran.cnr.berkeley.edu)... 169.229.201.201, 2607:f140:0:8000::201 
Connecting to cran.cnr.berkeley.edu (cran.cnr.berkeley.edu)|169.229.201.201|:80... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 1571788 (1.5M) [application/x-gzip] 
Saving to: ‘/tmp/RtmpwWvA3s/downloaded_packages/ggplot2_2.1.0.tar.gz’ 

/tmp/RtmpwWvA3s/downloaded_packages/ggplot2_2.1.0.ta 100%[========================================================================================================================>] 1.50M 1.32MB/s in 1.1s 

2016-04-26 18:29:17 (1.32 MB/s) - ‘/tmp/RtmpwWvA3s/downloaded_packages/ggplot2_2.1.0.tar.gz’ saved [1571788/1571788] 

* installing *source* package ‘ggplot2’ ... 
** package ‘ggplot2’ successfully unpacked and MD5 sums checked 
** R 
** data 
*** moving datasets to lazyload DB 
** inst 
** preparing package for lazy loading 
** help 
*** installing help indices 
** building package indices 
** installing vignettes 
** testing if installed package can be loaded 
* DONE (ggplot2) 

The downloaded source packages are in 
     ‘/tmp/RtmpwWvA3s/downloaded_packages’ 

您可以設置選項中~/.Rprofile或相應Rprofile.site