欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于R/RStudio中安裝包“無法與服務(wù)器建立連接”的解決方案

 更新時間:2021年04月02日 11:03:39   作者:truffle528  
這篇文章主要介紹了基于R/RStudio中安裝包“無法與服務(wù)器建立連接”的解決方案,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

這幾天在用RStudio寫程序的時候突然出現(xiàn)無法從網(wǎng)絡(luò)直接安裝r包的問題,也無法從本地直接安裝。

通過多方嘗試找到了問題解決的辦法,現(xiàn)在記錄在這里。

程序報(bào)錯如下:

> install.packages('REmap')
Warning in install.packages :
 unable to access index for repository https://cran.rstudio.com/src/contrib:
 cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
 unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
 cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
Warning in install.packages :
 unable to access index for repository https://cran.rstudio.com/src/contrib:
 cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
 unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
 cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
Warning in install.packages :
 package ‘REmap' is not available (for R version 3.4.1)
Warning in install.packages :
 unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/3.4:
 cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/PACKAGES'
Warning in install.packages :
 unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4:
 cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4/PACKAGES'
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
 cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
 cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'

網(wǎng)絡(luò)上主流的解決方式是在tools-global options-packages中切換下載的鏡像,有很多人反映他們的問題通過這個方法得到了解決,但是我換過很多鏡像都沒有用。

另一種方式是修改文件,在安裝文件夾中找到Rprofile.site文件,我的路徑是D:\Program Files\R\R-3.4.1\etc,用記事本打開,在里面添加語句:  

# set a CRAN mirror
local({r <- getOption(“repos”)
r[“CRAN”] <- “http://mirrors.tuna.tsinghua.edu.cn/CRAN/”
options(repos=r)}

這也是設(shè)置鏡像的方法,與方法一相同。對我也沒用。

之后了解到R中install.packages()是從ie瀏覽器中連接鏡像的,所以無法連接服務(wù)器很可能是在ie這一環(huán)節(jié)出現(xiàn)了問題。

打開電腦的ie瀏覽器看能不能正常上網(wǎng),如果顯示代理問題,在工具-internet選項(xiàng)-連接中將局域網(wǎng)設(shè)置里的代理服務(wù)器這一項(xiàng)去掉勾選。這樣就可以正常上網(wǎng)了。再檢查RStudio也能夠正常安裝r包了。

之后出現(xiàn)另外一個問題:  

> install.packages('sp')
trying URL 'https://cran.wu.ac.at/bin/windows/contrib/3.4/sp_1.2-5.zip'
Content type 'application/zip' length 1538503 bytes (1.5 MB)
downloaded 1.5 MB

package ‘sp' successfully unpacked and MD5 sums checked
Warning in install.packages :
 unable to move temporary installation ‘D:\Program Files\R\R-3.4.1\library\file4041367c44\sp' to ‘D:\Program Files\R\R-3.4.1\library\sp'

The downloaded binary packages are in
 C:\Users\asus\AppData\Local\Temp\RtmpWOz6Xu\downloaded_packages

無法將安裝包從臨時目錄中轉(zhuǎn)移,原因是殺毒軟件可能禁止了這樣的操作。

在殺毒軟件的白名單中加入R安裝在的文件夾,重新啟動RStudio問題即可解決。

或者比較麻煩一點(diǎn)的話就是在臨時目錄中解壓這個壓縮文件到R安裝目錄中的library文件夾中。

補(bǔ)充:R或RStudio下載包時出錯解決方案

當(dāng)我們想要在R&RStudio中下載包時可能會出現(xiàn)如下類似錯誤

在如下目錄中的Rprofile.site文件中對應(yīng)位置增加一條代碼即可:

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

修改好后,再次下載即可成功!

以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。

相關(guān)文章

最新評論